#变量
#在tensorflow中如果要使用变量的话必须进行初始化操作
import tensorflow as tf
x = tf.Variable([1,2])
a = tf.constant([3,3])
#增加一个减法op
sub = tf.subtract(x, a)
#增加一个加法op
add = tf.add(x, sub)
init = tf.global_variables_initializer() #初始化全局的变量
with tf.Session() as sess:
sess.run(init)
print(sess.run(sub))
print(sess.run(add))
tensorflow中变量
最新推荐文章于 2021-11-22 21:49:25 发布