In [1]:
import tensorflow as tf


/home/minesh/anaconda3/lib/python3.6/importlib/_bootstrap.py:219: RuntimeWarning: compiletime version 3.5 of module 'tensorflow.python.framework.fast_tensor_util' does not match runtime version 3.6
  return f(*args, **kwds)

constants


In [12]:
node1 = tf.constant(3.0, tf.float32)
node2 = tf.constant(4.0)
print(node1,node2)


Tensor("Const_4:0", shape=(), dtype=float32) Tensor("Const_5:0", shape=(), dtype=float32)

In [5]:
sess = tf.Session()

In [9]:
sess.list_devices()


Out[9]:
[_DeviceAttributes(/job:localhost/replica:0/task:0/device:CPU:0, CPU, 268435456)]

In [10]:
print(sess.run([node1,node2]))


[3.0, 4.0]

In [13]:
node3 = tf.add(node1,node2) # need to be exact same data type

In [14]:
print("result : ",sess.run(node3))


result :  7.0

place holders


In [15]:
a = tf.placeholder(tf.float32)
b = tf.placeholder(tf.float32)
adder_node = a + b

In [19]:
sess.run(adder_node,{a:3.0,b:4.5})


Out[19]:
7.5

In [20]:
sess.run(adder_node,{a:[3.0,1.0],b:[2,4.5]})


Out[20]:
array([ 5. ,  5.5], dtype=float32)

In [21]:
add_and_triple = adder_node * 3

In [23]:
sess.run(add_and_triple,{a:[3.0,1.0],b:[2,4.5]})


Out[23]:
array([ 15. ,  16.5], dtype=float32)

tensor Board


In [30]:
writer = tf.summary.FileWriter("./my_graph",sess.graph)
writer.close()

In [31]:
sess.graph
sess.close()

In [32]:
!tensorboard --logdir=./my_graph


/home/minesh/anaconda3/lib/python3.6/importlib/_bootstrap.py:219: RuntimeWarning: compiletime version 3.5 of module 'tensorflow.python.framework.fast_tensor_util' does not match runtime version 3.6
  return f(*args, **kwds)
TensorBoard 0.4.0rc3 at http://Immortal:6006 (Press CTRL+C to quit)
^C

In [ ]: