错误:
AttributeError: __enter__
源码:
n = tf.sqrt(tf.reduce_sum(tf.square(tf.Variable([[1,2,3],[2,3,4]],dtype=tf.float32)),keep_dims=True))
with tf.Session as sess:
sess.run(tf.global_variables_initializer())
n1 = sess.run(n)
错误原因:
with tf.Session as sess:
以上代码忘记在tf.Session后边加()了
正确:
with tf.Session() as sess: