tensor_session.py 529 B

123456789101112131415161718192021
  1. # tensor described with ( name shape type )
  2. # data types:
  3. # int: tf.int8, 16, 32, 64, uint 8
  4. # float: tf.float32, float64
  5. # bool: tf.bool
  6. # complex: tf.complex64, complex128
  7. import tensorflow as tf
  8. a = tf.constant([1.0, 3.0], name="a")
  9. b = tf.constant([3.0, 6.0], name="b")
  10. sum = a+b
  11. print tf.add(a, b, name="add")
  12. with tf.Session().as_default():
  13. print (sum.eval())
  14. with tf.Session() as sess:
  15. result = sess.run(a+b)
  16. print result
  17. writer = tf.summary.FileWriter("logs", tf.get_default_graph())
  18. writer.close()