@@ -284,10 +284,13 @@ def model_fn(features, labels, mode, params):
284
284
train_op = optimizer .minimize (combined_cost , global_step = global_step )
285
285
286
286
# Computations to be executed on CPU, outside of the main TPU queues.
287
- def eval_metrics_host_call_fn (policy_output , value_output , pi_tensor ,
288
- value_tensor , policy_cost , value_cost ,
289
- l2_cost , combined_cost , step ,
290
- est_mode = tf .estimator .ModeKeys .TRAIN ):
287
+ def eval_metrics_host_call_fn (
288
+ features ,
289
+ policy_output , value_output ,
290
+ pi_tensor , value_tensor ,
291
+ policy_cost , value_cost ,
292
+ l2_cost , combined_cost ,
293
+ step , est_mode = tf .estimator .ModeKeys .TRAIN ):
291
294
policy_entropy = - tf .reduce_mean (tf .reduce_sum (
292
295
policy_output * tf .log (policy_output ), axis = 1 ))
293
296
# pi_tensor is one_hot when generated from sgfs (for supervised learning)
@@ -306,6 +309,8 @@ def eval_metrics_host_call_fn(policy_output, value_output, pi_tensor,
306
309
307
310
value_cost_normalized = value_cost / params ['value_cost_weight' ]
308
311
avg_value_observed = tf .reduce_mean (value_tensor )
312
+ avg_stones_black = tf .reduce_mean (tf .reduce_sum (features [:,:,:,1 ], [1 ,2 ]))
313
+ avg_stones_white = tf .reduce_mean (tf .reduce_sum (features [:,:,:,0 ], [1 ,2 ]))
309
314
310
315
with tf .variable_scope ('metrics' ):
311
316
metric_ops = {
@@ -315,13 +320,17 @@ def eval_metrics_host_call_fn(policy_output, value_output, pi_tensor,
315
320
'l2_cost' : tf .metrics .mean (l2_cost ),
316
321
'policy_entropy' : tf .metrics .mean (policy_entropy ),
317
322
'combined_cost' : tf .metrics .mean (combined_cost ),
318
- 'avg_value_observed' : tf .metrics .mean (avg_value_observed ),
319
323
'policy_accuracy_top_1' : tf .metrics .mean (policy_output_in_top1 ),
320
324
'policy_accuracy_top_3' : tf .metrics .mean (policy_output_in_top3 ),
321
325
'policy_top_1_confidence' : tf .metrics .mean (policy_top_1_confidence ),
326
+ 'value_confidence' : tf .metrics .mean (tf .abs (value_output )),
327
+
328
+ # Metrics about input data
322
329
'policy_target_top_1_confidence' : tf .metrics .mean (
323
330
policy_target_top_1_confidence ),
324
- 'value_confidence' : tf .metrics .mean (tf .abs (value_output )),
331
+ 'avg_value_observed' : tf .metrics .mean (avg_value_observed ),
332
+ 'avg_stones_black' : tf .metrics .mean (avg_stones_black ),
333
+ 'avg_stones_white' : tf .metrics .mean (avg_stones_white ),
325
334
}
326
335
327
336
if est_mode == tf .estimator .ModeKeys .EVAL :
@@ -349,6 +358,7 @@ def eval_metrics_host_call_fn(policy_output, value_output, pi_tensor,
349
358
return summary .all_summary_ops () + [cond_reset_op ]
350
359
351
360
metric_args = [
361
+ features ,
352
362
policy_output ,
353
363
value_output ,
354
364
labels ['pi_tensor' ],
0 commit comments