Machine Learning for Python by Google
More information can be found at tensorflow.org
*Tensor* - N dimensional array. A tensor can be a scalar, a vector, or a matrix.
*Graph* - Describes what you are actually going do with the N dimensional arrays (the tensors). In other words, as your data flows through your model, what kind of computations and transformations are you going to do on that data.
# standard way of importing the library
import tensorflow as tf
import sys
print('Python version ' + sys.version)
print('Tensorflow version ' + tf.VERSION)
Python version 3.5.1 |Anaconda custom (64-bit)| (default, Feb 16 2016, 09:49:46) [MSC v.1900 64 bit (AMD64)] Tensorflow version 0.12.0-rc0
These are static values that are known before we run our model.
tf.constant?
# declare two constants
a = tf.constant(5.0)
b = tf.constant(6.0)
# let's multiply our two tensors
c = a * b
A *Session* object encapsulates the environment in which Operation objects are executed, and Tensor objects are evaluated.
# Run your graph inside a session
with tf.Session() as sess:
print(sess.run(c)) # method 1
print(c.eval()) # method 2
30.0 30.0
Notice that *a, b, and c* are all tensors
print(type(a))
print(type(b))
print(type(c))
<class 'tensorflow.python.framework.ops.Tensor'> <class 'tensorflow.python.framework.ops.Tensor'> <class 'tensorflow.python.framework.ops.Tensor'>
This tutorial was created by HEDARO