tf.set_random_seed(seed)
tf.add(a,b,verify_shape = true, name = 'a')
constant are stored in the graphic definition.
with tf.Session() as sess:
print sess.graph.as_graph_def()
a = tf.Variable(tf.zeros([784,10]))
init = tf.global_variables_initializer(a,b], name = 'init_ab')
with tf.Session() as sess:
sess.run(init)
sess.run(W.initializer)
print(W.eval()).
W = tf.Variable(10)
assign_op = W.assign(100)
with tf.Session() as sess:
sess.run(W.initializer) -------> 结果:10
print W.eval() ---------------> 结果:10
sess.run(assign_op) -------------> 结果:100
sess.run(W.initializer)
print(W.eval())
W.assign_add(10) -----------> W + 10W.assign_sub(2) ------------> W - 2
Notice: The operation in different sessions give a copy, not a view, of the original variable.