Der*_*erk 5 python deep-learning tensorflow
查看屏幕截图。没有批量标准化的是蓝线。上图中的精度,下图中的损耗。因此,在没有BN的情况下,损耗会缓慢降低,而精度则会缓慢提高,这是预期的行为。
但是,然后我尝试批量标准化。训练损失很快收敛到接近零的值。比没有情况下要好得多,但是在训练和测试集上的测试准确性都会给出较差的结果。

我基于此实现:http : //ruishu.io/2016/12/27/batchnorm/ 因此,将批处理规范添加到这样的层:
h1_p_bn = tf.contrib.layers.batch_norm(h1_p, center=True, scale=True, is_training=self.is_training,scope='bn1')
Run Code Online (Sandbox Code Playgroud)
使用model.is_training一个占位符,该占位符在测试准确性(上部图)时设置为零。
我也这样做:
# Requirement from tf.contrib.layers.batch_norm
update_ops = tf.get_collection(tf.GraphKeys.UPDATE_OPS)
with tf.control_dependencies(update_ops):
# Ensures that we execute the update_ops before performing the train_step
optimizer = tf.train.AdamOptimizer(learning_rate)
self.train_op = optimizer.minimize(self.loss, global_step=global_step)
Run Code Online (Sandbox Code Playgroud)
有什么想法或建议吗?
| 归档时间: |
|
| 查看次数: |
2120 次 |
| 最近记录: |