更新时间:2023-12-02 12:18:46
首先,你不需要使用 summary_hook.您只需要在指定 logits 后立即使用 tf.metrics
指定所需的指标.
First of all, you don't need to use summary_hook. You just need to specify desired metrics with tf.metrics
right after you specify logits.
logits = tf.layers.dense(inputs=dropout, units=10)
predictions = {
"classes": tf.argmax(input=logits, axis=1),
"probabilities": tf.nn.softmax(logits, name="softmax_tensor")
}
accuracy = tf.metrics.accuracy(labels=labels, predictions=predictions['classes']
tf.summary.scalar('acc', accuracy[1])
然后把这个tf.logging.set_verbosity(tf.logging.INFO)
在您输入之后,如果您还没有这样做的话.
And put this
tf.logging.set_verbosity(tf.logging.INFO)
right after your inputs, if you haven't done so.
您可以通过将 eval_metric_ops = {'accuracy':accuracy}
dict 插入到 tf.estimator.EstimatorSpec
You can plot evaluation metrics by inserting eval_metric_ops = {'accuracy': accuracy}
dict to tf.estimator.EstimatorSpec
您可以使用 tf.summary
来可视化图像、权重和偏差等.
You can use tf.summary
for visualizing images, weights and biases, etc.