我使用slim.evaluation.evaluation_loop
作为评估我训练的模型的单独过程。要获取指标更新操作,请使用streaming metrics
。我的代码看起来像,
## Compute the metrics
names_to_values, names_to_updates = slim.metrics.aggregate_metric_map({
'accuracy' : slim.metrics.streaming_accuracy(tf.to_int32(tf.argmax(test_predictions, 1)),test_labels),
})
## Aggregate the metrics
summary_ops = []
for metric_name, metric_value in names_to_values.iteritems():
op = tf.summary.scalar(metric_name, metric_value)
op = tf.Print(op, [metric_value], metric_name)
summary_ops.append(op)
## Evaluation parameter setup
slim.get_or_create_global_step()
test_summary_dir = {test summaries directory}
eval_interval_secs = {test interval in seconds} # How often to run the evaluation.
num_examples = {test set size}
batch_size = {test batch size}
num_batches = math.ceil(num_examples / float(batch_size))
slim.evaluation.evaluation_loop(
master="",
checkpoint_dir={checkpoint directory name},
logdir=test_summary_dir,
num_evals=num_batches,
eval_op=names_to_updates.values(),
summary_op=tf.summary.merge(summary_ops),
eval_interval_secs=eval_interval_secs,
)
我的问题是,当使用streaming metrics
时,Tensorflow会不断累积指标。这意味着早期检查点的准确性也被计算在内。如果我们需要评估特定的检查点,这是不对的。
在这个解释过的设置中,有没有办法在每个纪元后重置评估准确度?
否则,除了streaming_metrics
之外还有其他任何公制计算方法可以解决这个问题吗?
提前谢谢!