【问题标题】:What does batch normalization do if the batch size is one?如果批量大小为 1,批量标准化会做什么?
【发布时间】:2018-02-09 14:56:31
【问题描述】:

我目前正在阅读 Ioffe 和 Szegedy 关于批量标准化的论文,我想知道如果将批量大小设置为 1 会发生什么。小批量平均值(基本上是激活本身的值)和方差(应该是零加上常数 epsilon)的计算将导致归一化维度为零。

然而 tensorflow 中的这个小例子表明正在发生一些不同的事情:

test_img = np.array([[[[50],[100]],
                   [[150],[200]]]], np.float32)
gt_img = np.array([[[[60],[130]],
                [[180],[225]]]], np.float32)
test_img_op = tf.convert_to_tensor(test_img, tf.float32)
norm_op = tf.layers.batch_normalization(test_img_op)

loss_op = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(labels = gt_img,
                                                             logits = norm_op))

update_ops = tf.get_collection(tf.GraphKeys.UPDATE_OPS)
with tf.control_dependencies(update_ops):
    optimizer_obj = tf.train.AdamOptimizer(0.01).minimize(loss_op)
with tf.Session() as sess:
    sess.run(tf.group(tf.global_variables_initializer(), 
                      tf.local_variables_initializer()))
    print(test_img)
    while True:
        new_img, op, lossy, trainable = sess.run([norm_op, optimizer_obj, loss_op, tf.trainable_variables()])
        print(trainable)
        print(new_img)

那么 TensorFlow 有何不同之处(移动平均线?!)?

谢谢!

【问题讨论】:

  • 您能详细说明一下那篇论文吗?您从哪里得知它正在执行实例规范化之类的操作?

标签: tensorflow batch-normalization


【解决方案1】:

由于 beta 是默认开启的翻译学习参数,归一化后的输出不一定是零。

输入均值和方差的移动平均值将在训练期间计算并可用于测试(如果您相应地设置了is_training)。

【讨论】:

    猜你喜欢
    • 2020-04-26
    • 1970-01-01
    • 2018-06-27
    • 2019-11-13
    • 2018-04-09
    • 2017-03-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多