Tensorflow graph test

>>> import tensorflow as tf

>>> a= tf.constant(6,name='constant_a')

>>> b=tf.constant(3,name='constant_b')
>>> c= tf.constant(10,name='constant_c')
>>> d= tf.constant(5,name='constant_d')
>>> mul = tf.multiply(a,b,name='mul')
>>> div =tf.div(c,d,name='div')
>>> addn = tf.add_n([mul,div],name='addn')
>>> print(addn)
Tensor("addn:0", shape=(), dtype=int32)
>>> print(a)
Tensor("constant_a:0", shape=(), dtype=int32)
>>> sess=tf.Session()
>>> sess.run(addn)
20
>>> sess.run(mul)
18

>>> sess.run(div)

>>> 2

# write the graph writer  

>>>writer = tf.summary.FileWriter('./m2_example',sess.graph)

>>>writer.close()

>>>sess.close()




猜你喜欢

转载自blog.csdn.net/chenxin0215/article/details/81019152