I use the built-in method tf.metrics.precision to evaluate my model. I was looking through its definition, but the local variables are never reset.
Shouldn't they be reset after each epoch in order to remove the counts from the last epochs? Is this done automatically and I was just overlooking it in the source code, or am I supposed to do it? If the latter is true, how do I reset the local variables? I didn't read anything about it in the documentation.
Variables for keeping track of metrics are created with the metric_variable
function and thus added to the collection with key tf.GraphKeys.METRIC_VARIABLES
. After you have defined all your metrics, you can have a reset operation like this:
reset_metrics_op = tf.variables_initializer(tf.get_collection(tf.GraphKeys.METRIC_VARIABLES))
And run it after each epoch is finished.