tensorflow Variable 变量

import tensorflow as tf

state = tf.Variable(0, name='counter')

one = tf.constant(1)

new_value = tf.add(state, one)

update = tf.assign(state, new_value)

init = tf.global_variables_initializer()

with tf.Session() as sess:
    sess.run(init)

    for _ in range(3):
        sess.run(update)
        print(sess.run(state))

https://morvanzhou.github.io/tutorials/machine-learning/tensorflow/2-4-variable/

http://www.waitingfy.com/archives/4902

4902

Leave a Reply

Name and Email Address are required fields.
Your email will not be published or shared with third parties.