【发布时间】:2017-12-26 15:33:29
【问题描述】:
当我尝试在张量流中初始化变量时,我遇到了异常。下面是代码。有人可以帮忙吗?
import tensorflow as tf
node1 = tf.constant(3.0, dtype=tf.float32)
node2 = tf.constant(4.0) # also tf.float32 implicitly
print(node1, node2)
init_g = tf.global_variables_initializer()
init_l = tf.local_variables_initializer()
sess = tf.Session()
sess.run(init_g)
sess.run(init_l)
print(sess.run([node1, node2]))
node3 = tf.add(node1, node2)
print(node3) #prints type in tensorflow
print(sess.run([node3]))
node4 = tf.Variable([.3], dtype=tf.float32)
print(sess.run([node4]))
【问题讨论】:
标签: python-3.x tensorflow