版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u010255642/article/details/82314270
tf.count_up_to
tf.count_up_to(
ref,
limit,
name=None
)
增加“ref
”直到它达到“limit
”
参数:
ref
:一个变量,必须是int32
,int64类型。必要来自于一个
scalarVariable
节点limit
:一个int,如果增加ref在limit之上,将报错
'OutOfRange' 。name
: 操作名字(可选)
返回:
tensor,和ref类型相同,在增长之前输入的副本,如果没有其他修改输入,所产生的值将是不同的。
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 27 11:16:32 2018
@author: myhaspl
"""
import tensorflow as tf
x = tf.Variable(0, name="my_x")
add_var=tf.count_up_to(x,1000)
init_op = tf.global_variables_initializer()
sess=tf.Session()
with sess:
sess.run(init_op)
print sess.run(add_var)
print x.eval()
print sess.run(add_var)
print x.eval()
0
1
1
2