打印输出张量的值的方法
import tensorflow as tfzeros = tf.zeros([3,3])
with tf.Session():print(zeros.eval())
sess = tf.Session()
print(sess.run(zeros))
打印输出tensor变量的值的方法
import tensorflow as tfones=tf.Variable(tf.ones([3,3]))
inter_sess=tf.InteractiveSession()
ones.initializer.run()
print(inter_sess.run(ones))
inter_sess=tf.InteractiveSession()
tf.global_variables_initializer().run()
print(inter_sess.run(ones))
sess=tf.Session()
sess.run(tf.global_variables_initializer())
print(sess.run(ones))
with tf.Session() as sess:sess.run(tf.global_variables_initializer())print(sess.run(ones))