tf.set_random_seed(seed)

tf.add(a,b,verify_shape = true, name = 'a')

tensorflow 命令集合

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 + 10

      W.assign_sub(2)     ------------> W - 2

      Notice: The operation in different sessions give a copy, not a view, of the original variable.


相关文章:

  • 2021-11-25
  • 2021-06-15
  • 2021-12-19
  • 2021-11-30
  • 2021-05-30
  • 2021-08-22
猜你喜欢
  • 2022-02-19
  • 2021-11-23
  • 2021-04-21
  • 2021-05-14
  • 2021-04-02
  • 2022-02-08
  • 2021-08-05
相关资源
相似解决方案