title: Modifying the local variable accuracy/total:0
body: <p>I am using ResNet-50 with estimator.py</p>
  <p>I am using tf.compat.v1.metrics.accuracy to calculate the accuracy as:</p>
  <pre><code>accuracy = tf.compat.v1.metrics.accuracy(
              labels=tf.argmax(labels, axis=1),
              predictions=tf.argmax(p_logits, axis=1),
  </code></pre>
  <p>And I am using chekpoints to save models.</p>
  <p>The accuracy function creates two local variables, <strong>total</strong> and <strong>count</strong> that are used to compute the frequency with which predictions matches labels. This frequency is ultimately returned as accuracy: an idempotent operation that simply divides total by count</p>
  <p>I realize that when I am resuming my training, the value of the accuracy/total is reset to zero.</p>
  <p>I am printing the metric using Looging tensorhook:</p>
  <pre><code>logging_hook = tf.estimator.LoggingTensorHook(
                  {&quot;upd_acc&quot;: accuracy[1],&quot;t_acc&quot;: accuracy[0]
                   },
                  every_n_iter=500
              )
  </code></pre>
  <p>Without resuming I get:</p>
  <pre><code>t_acc = 0.0, upd_acc = 0.0
  t_acc = 0.0, upd_acc = 0.13
  t_acc = 0.13, upd_acc = 0.20666666
  t_acc = 0.20, upd_acc = 0.23
  t_acc = 0.23, upd_acc = 0.24 (here save a model)
  t_acc = 0.24, upd_acc = 0.29333332
  t_acc = 0.29, upd_acc = 0.33142856
  t_acc = 0.33, upd_acc = 0.345
  </code></pre>
  <p>But when resuming from the last model saved t_acc gets back to zero.</p>
  <pre><code>Restoring parameters from model.ckpt-398
  t_acc = 0.0, upd_acc = 0.28
  t_acc = 0.28, upd_acc = 0.35
  t_acc = 0.35, upd_acc = 0.36
  t_acc = 0.36, upd_acc = 0.37
  </code></pre>
  <p>Ignore the bad accuracy.</p>
  <p>How can I recover the last value of t_acc when resuming training?</p>
  <p>The reason why I want to recover the value is because when resuming is producing annoying &quot;bumps&quot; in the accuracy vs epochs plot.</p>
  <p>I am printing the value of the local variables:</p>
  <pre><code>stream_vars = [i for i in tf.local_variables()]
  logging.info(stream_vars)
  </code></pre>
  <p>Getting:</p>
  <pre><code>[&lt;tf.Variable 'accuracy/total:0' shape=() dtype=float32_ref&gt;, &lt;tf.Variable 'accuracy/count:0' shape=() dtype=float32_ref&gt;]
  </code></pre>