Friday, 29 December 2017

Tensorflow with Jupyter Notebook - getting started

I started learning Tensorflow with this awesome course on Udemy.

Even if you don't want to buy the course (although it's worth it's price). You can play with Tensorflow yourself using jupyter notebook. So here are a simple steps to make it possible (note: not all packages mentioned in step 4 are necessary. It's just convenient to have them when doing real projects)


  1. First install Anaconda python distribution with Anacaonda installer docs for your OS
  2. Create new conda environment with:
    conda create -n tensorflow python=3.5
    where tensorflow is your env name
  3. Activate tensorflow env with:
    source activate tensorflow
    (Linux and OSX)
    or
    activate tensorflow
    (Windows)
  4. From terminal install conda packages with:
    conda install jupyter
    conda install numpy
    conda install pandas
    conda install scikit-learn
    conda install matplotlib
    conda install tensorflow
    (or conda install -c conda-forge tensorflow)
  5. Run Jupyter Notebook using:
    jupyter notebook
Finally you can test your environment in Jupyter inserting few commands in a new book.

So after browser shows jupter dir structure press 'new' and select Python 3. In a new document start typing:

import tensorflow as tf

and press shift+enter to run the code.

No error should appear. Then do the same with lines:

hello = tf.constant("Hello World")
sess = tf.Session()
print(sess.run(hello))


If everything went well you should see something like on the screenshot below.


Jupyter Notebook with tensorflow



No comments:

Post a Comment

Simple way to deploy docker app on production machine

Small software house house/freelancer life isn't easy. Reading HN post about fancy new tech is amusing but as much as it is nice to read...