tensorflow - Understanding tf.metrics and slims streaming metric -


i'm not sure if understand tf.metrics , tf.contrib.slim.metrics correctly.

here general flow of program:

# setup of neural network...  # adding metrics dict_metrics[name] = compute_metric_and_update_op()  # getting list of metrics , updates names_to_values, names_to_updates = slim.metrics.aggregate_metric_map(dict_metrics)  # calling tf.slim evaluate slim.evaluation.evaluation_loop(eval_op=list(names_to_updates.values()), ...) 

let's assume want compute accuracy. have 2 options: a) compute accuracy on pixels in images in batches b) compute accuracy on pixels in 1 image , take average of accuracies on images in batches.

for version a) write:

name = "slim/accuracy_metric" dict_metrics[name] = slim.metrics.streaming_accuracy(     labels, predictions, weights=weights, name=name) 

which should equivalent to:

name = "accuracy_metric" accuracy, update_op = tf.metrics.accuracy(     labels, predictions, weights=weights, name=name) dict_metrics[name] = (accuracy, update_op) 

furthermore, should pointless or wrong add line

dict_metrics["stream/" + name] = slim.metrics.streaming_mean(accuracy) 

because accuracy tf.metrics.accuracy computed on batches via update_op. correct?

if go option b), can achieve effect this:

accuracy = my_own_compute_accuracy(labels, predictions) dict_metrics["stream/accuracy_own"] = \     slim.metrics.streaming_mean(accuracy) 

where my_own_compute_accuracy() computes symbolic accuracy labels , predictions tensor not return update operation. in fact, version calculate accuracy on single image or single batch? basically, if set batch size size of complete dataset, metric matches output of slim.metrics.streaming_accuracy?

lastly, if add same update operation twice, called twice?

thank you!

yes, slim streaming accuracy computes mean of per-batch accuracy on entire dataset (if 1 epoch).

for accuracy function depends on how implement it.


Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -