tensorflow1.X会话求值

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import tensorflow as tf 


var1 = tf.constant([1], tf.float32)

sess = tf.Session(); sess.run(tf.global_variables_initializer())

#方法一
value1_var1 = sess.run(var1)
print(value1_var1)
#[1.]

#方法二
value2_var1 = var1.eval(session=sess)
print(value2_var1)
#[1.]

转载请注明来源 https://tianweiye.github.io