标签:add imp def ons const shape val oba variables
生成新的计算图,并完成常量初始化,在新的计算 图中完成加法计算import tensorflow as tf
g1=tf.Graph()
with g1.as_default():
???value=[1.,2.,3.,4.,5.,6.]
???init = tf.constant_initializer(value)
???x=tf.get_variable("x",initializer=init,shape=[2,3])
???y=tf.get_variable("y",shape=[2,3],initializer=tf.ones_initializer())
???result=tf.add(x,y,name="myadd")
with tf.Session(graph=g1) as sess:
???tf.global_variables_initializer().run()
???with tf.variable_scope("",reuse=True):
???????print(sess.run(tf.get_variable("x")))
???????print(sess.run(tf.get_variable("y")))
???print(sess.run(result))
标签:add imp def ons const shape val oba variables
原文地址:http://blog.51cto.com/13959448/2318744