caicloud/tensorflow-tutorial

第二版 第五章 5.2.1节关于计算交叉熵的问题 pp:99

skx300 opened this issue · 3 comments

我看这里计算了使用非滑动平均和滑动平均的inference。但是在计算交叉熵的时候,只用到了非滑动平均的预测值。而在评价accuracy的时候,却是用了使用滑动平均的预测值。请问这里为什么不用使用滑动平均的预测值来计算交叉熵呢?因为评价的时候就是用了使用滑动平均的预测值啊。

代码片段如下:

    # 计算交叉熵及其平均值
    cross_entropy = tf.nn.sparse_softmax_cross_entropy_with_logits(logits=y, labels=tf.argmax(y_, 1))
    cross_entropy_mean = tf.reduce_mean(cross_entropy)
    # 计算正确率
    correct_prediction = tf.equal(tf.argmax(average_y, 1), tf.argmax(y_, 1))
    accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

Prevent issues from auto-closing with an /lifecycle frozen comment.

If this issue is safe to close now please do so with /close.

/lifecycle stale

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

/lifecycle rotten
/remove-lifecycle stale

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

/close