Tensorflow 2: Tensors

Expanding from my previous post:

I will create a new jupyter notebook called 2_Tensors.ipynb.  All my code can be found on github.


A tensor is simply an array of data. The tensor rank is the number of dimensions the data has.  Tensors can be defined in the tensorflow API or using python native data types.  This means we can use libraries like numpy.


Previously we had executed the graph by using 3 separate steps

But it is better to use the following form

This will automatically close the session.


Then executing shows that the run command essentially asks Tensorflow to solve for that variable.

So the output is.

You may also see .eval() used instead of .run() sometimes.  .eval(X) is essentially shorthand for tf.get_default_session().run(X).  Eval will always use the default session where as .run(X) can be executed on different sessions.

Direct from Tensorflow documentation

Both give the same answer of 5.0

Continue… onto Tensorboard.