如何记录或查看在使用 dropout 训练 TensorFlow 神经网络时使用的成本?
How do I log or view the cost used in training a TensorFlow neural network with dropout?
如何查看训练 TensorFlow neural network with dropout 时实际使用的 dropout 的准确性和成本?
不出所料,每次我 运行 一个 summary,例如与
train_writer.add_summary(sess.run(merged, feed_dict=foo), step)
或
print(sess.run(accuracy, feed_dict=foo))
如果网络包含 dropout,并且 foo
提供 1.0 以外的“保持概率”,我将得到不同的值,例如,我每次都会得到不同的损失或准确度——例如, 三个直接连续的精度计算
print(sess.run(accuracy, feed_dict=foo))
print(sess.run(accuracy, feed_dict=foo))
print(sess.run(accuracy, feed_dict=foo))
可能会给出类似
的东西
75.808
75.646
75.770
虽然这些大致相同,但并不完全相同,大概是因为我每次评估时,网络都会丢弃不同的节点。这样做的结果一定是我从来没有看到培训中实际遇到的成本。
如何记录或查看实际用于训练带 dropout 的 TensorFlow 神经网络的成本(或使用网络计算的其他汇总值)?
问题出在哪里?如果你调用随机网络三次,你 应该 得到三个不同的值。当您从网络记录损失时,您记录的是训练期间实际使用的损失。基本上你可以从你的计算图中读出值,比如:
for i in range(100):
batch_xs, batch_ys = mnist.train.next_batch(100)
cross_entropy = -tf.reduce_sum(y_ * tf.log(y))
_, loss_val = sess.run([train_step, cross_entropy],
feed_dict={x: batch_xs, y_: batch_ys})
print 'loss = ' + loss_val
这将打印在训练步骤期间计算的损失(它不会计算两次,因此不会对 dropout 输出掩码进行重新采样)。
如果你想看到 "what would be the accuracy on train set if I stop learning now" 你需要一个 eval graph https://www.tensorflow.org/versions/r0.8/tutorials/mnist/tf/index.html#evaluate-the-model ,它会告诉你的网络,是时候改变 dropout单位从随机到 scaling/averaging 结果。
如何查看训练 TensorFlow neural network with dropout 时实际使用的 dropout 的准确性和成本?
不出所料,每次我 运行 一个 summary,例如与
train_writer.add_summary(sess.run(merged, feed_dict=foo), step)
或
print(sess.run(accuracy, feed_dict=foo))
如果网络包含 dropout,并且 foo
提供 1.0 以外的“保持概率”,我将得到不同的值,例如,我每次都会得到不同的损失或准确度——例如, 三个直接连续的精度计算
print(sess.run(accuracy, feed_dict=foo))
print(sess.run(accuracy, feed_dict=foo))
print(sess.run(accuracy, feed_dict=foo))
可能会给出类似
的东西75.808
75.646
75.770
虽然这些大致相同,但并不完全相同,大概是因为我每次评估时,网络都会丢弃不同的节点。这样做的结果一定是我从来没有看到培训中实际遇到的成本。
如何记录或查看实际用于训练带 dropout 的 TensorFlow 神经网络的成本(或使用网络计算的其他汇总值)?
问题出在哪里?如果你调用随机网络三次,你 应该 得到三个不同的值。当您从网络记录损失时,您记录的是训练期间实际使用的损失。基本上你可以从你的计算图中读出值,比如:
for i in range(100):
batch_xs, batch_ys = mnist.train.next_batch(100)
cross_entropy = -tf.reduce_sum(y_ * tf.log(y))
_, loss_val = sess.run([train_step, cross_entropy],
feed_dict={x: batch_xs, y_: batch_ys})
print 'loss = ' + loss_val
这将打印在训练步骤期间计算的损失(它不会计算两次,因此不会对 dropout 输出掩码进行重新采样)。
如果你想看到 "what would be the accuracy on train set if I stop learning now" 你需要一个 eval graph https://www.tensorflow.org/versions/r0.8/tutorials/mnist/tf/index.html#evaluate-the-model ,它会告诉你的网络,是时候改变 dropout单位从随机到 scaling/averaging 结果。