所以我读过,平均减法对图像非常重要,因为它使数据为零中心。 来自this讲座。
然而,将数据置零中心非常重要,并且通常也会看到每个像素的归一化。
然而,我在所有的MNIST和猫/狗分类教程中都没有在实践中看到这一点。它真的那么重要吗?如果您没有将数据置于零中心,会发生什么?任何人都可以指向我一个教程笔记本,最好在Tensorflow中,显示平均减法完成?
答案 0 :(得分:1)
输入归一化,特别是平均减法,确实是一个重要的预处理步骤,在实践中通常需要使SGD收敛。
当你说它在教程中几乎没有使用时,你就错了:它几乎无处不在。例如,tensorflow的CIFAR-10教程规范化图像here。
唯一常见的例外是MNIST,不幸的是它也是无所不在的CNN-101教程,或许留下了一种持久的印象,即图像规范化毕竟是可选的。
我通过比较有和没有标准化的结果,对tensorflow的deep MNIST tutorial做了一个小实验。
标准实施产生:
step 0, training accuracy 0.1
step 100, training accuracy 0.94
step 200, training accuracy 0.88
step 300, training accuracy 0.9
step 400, training accuracy 0.92
step 500, training accuracy 0.92
step 600, training accuracy 0.92
step 700, training accuracy 0.98
step 800, training accuracy 0.98
step 900, training accuracy 0.9
step 1000, training accuracy 0.94
step 1100, training accuracy 0.98
step 1200, training accuracy 0.96
step 1300, training accuracy 0.94
step 1400, training accuracy 0.98
step 1500, training accuracy 1
step 1600, training accuracy 0.94
step 1700, training accuracy 0.96
step 1800, training accuracy 1
step 1900, training accuracy 0.96
test accuracy 0.974
添加标准化时
x_image = tf.map_fn(lambda frame: tf.image.per_image_standardization(frame), x_image)
我获得了
step 0, training accuracy 0.1
step 100, training accuracy 0.86
step 200, training accuracy 0.92
step 300, training accuracy 0.86
step 400, training accuracy 0.94
step 500, training accuracy 0.98
step 600, training accuracy 0.94
step 700, training accuracy 0.96
step 800, training accuracy 1
step 900, training accuracy 0.92
step 1000, training accuracy 0.92
step 1100, training accuracy 0.98
step 1200, training accuracy 0.98
step 1300, training accuracy 0.96
step 1400, training accuracy 0.96
step 1500, training accuracy 1
step 1600, training accuracy 0.98
step 1700, training accuracy 0.96
step 1800, training accuracy 0.94
step 1900, training accuracy 1
test accuracy 0.974
最后,在两种情况下,我在2000步后获得了相同的(!)测试精度。因此,图像规范化不会降低性能,但不会增加太多。
真正的问题是,是什么让MNIST数据集如此特殊以至于它不会受益于图像规范化。这可能是由于图像的性质(通常是恒定的),或者是由于数据集(LeNet和变体)上常用的网络,这些网络足够浅,能够处理非零平均数据。