Python 如何在tensorflow评估期间打印当前评估步骤?
我正在尝试获取tensorflow评估的当前批次索引,但它不起作用。我的代码是关于评估图像分类器的Python 如何在tensorflow评估期间打印当前评估步骤?,python,tensorflow,Python,Tensorflow,我正在尝试获取tensorflow评估的当前批次索引,但它不起作用。我的代码是关于评估图像分类器的 def _create_local(name, shape, collections=None, validate_shape=True, dtype=tf.float32): """Creates a new local variable. Args: name: The name of the new or existing va
def _create_local(name, shape, collections=None, validate_shape=True,
dtype=tf.float32):
"""Creates a new local variable.
Args:
name: The name of the new or existing variable.
shape: Shape of the new or existing variable.
collections: A list of collection names to which the Variable will be added.
validate_shape: Whether to validate the shape of the variable.
dtype: Data type of the variables.
Returns:
The created variable.
"""
# Make sure local variables are added to tf.GraphKeys.LOCAL_VARIABLES
collections = list(collections or [])
collections += [tf.GraphKeys.LOCAL_VARIABLES]
return variables.Variable(
initial_value=tf.zeros(shape, dtype=dtype),
name=name,
trainable=False,
collections=collections,
validate_shape=validate_shape)
我的评价职能:
def _get_evaluation(channel):
with tf.name_scope("eval"):
result = _create_local('result_list', shape=[10, 4],dtype=tf.float32)
#my codes
# current evaluation step
currrent_step = tf.range(result[-1,-1], result[-1,-1] + FLAGS.batch_size)
return currrent_step
只需将c\U值传递给创建本地
def _get_evaluation(channel):
with tf.name_scope("eval"):
result = _create_local('result_list', shape=[10, 4],dtype=tf.float32)
# current evaluation step
c_value= _create_local('c_value', shape=(1,), dtype=tf.int32)