Printing additional learning metrics with Tensorflow Estimator

Is there a way for Tensorflow to print additional training metrics (e.g. batch accuracy) when using the Estimator API?

You can add a resume and view the result in Tensorboard (see another post), but I was wondering if there is an elegant way to get scalar totals printed during training. This is already happening to lose training, for example:

loss = 0.672677, step = 2901 (52.995 sec)

but it would be nice to have, for example,

loss = 0.672677, accuracy = 0.54678, step = 2901 (52.995 sec)

without any problems. I know that most of the time it’s more useful to print the accuracy of the test suite (I already do this using the validation monitor), but in this case I am also interested in the accuracy of batch training.

+6
1

, , , . , .

model_fn :

logging_hook = tf.train.LoggingTensorHook({"loss" : loss, 
    "accuracy" : accuracy}, every_n_iter=10)

# Rest of the function

return tf.estimator.EstimatorSpec(
    ...params...
    training_hooks = [logging_hook])

EDIT:

, ( ): tf.logging.set_verbosity(tf.logging.INFO)

+4

All Articles