【发布时间】: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