首页 > 其他 > 详细

tensorflow1.0 变量加法

时间:2020-03-15 00:09:49      阅读:70      评论:0      收藏:0      [点我收藏+]
import tensorflow as tf

state = tf.Variable(0,name=‘counter‘)
print(state.name)

one = tf.constant(1)
#常量加变量还是变量
new_value = tf.add(state,one)
#把新的值给state变量
update = tf.assign(state,new_value)

init = tf.initialize_all_variables()  #初始化所有变量

with tf.Session() as sess:
    sess.run(init)
    for _ in range(3):
        sess.run(update)
        print(sess.run(state))



1
2
3

  

tensorflow1.0 变量加法

原文:https://www.cnblogs.com/LiuXinyu12378/p/12495328.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!