哪种是进行图像归一化的正确方法?
Which is the correct way to do image normalization?
在为神经网络训练准备训练集时,我发现了两种可能的方法。
- 传统方法:在整个训练集上计算均值,并在发送到网络之前减去每个图像的固定均值。以类似的方式处理标准差。
- 我发现 tensorflow 提供了一个函数
tf.image.per_image_standardization
可以对 单个图像 . 进行归一化
不知哪种方式更合适?
两种方式都可以,选择主要取决于您读取数据的方式。
整个训练集 当您可以一次将整个数据集加载到一个 numpy 数组中时,规范化很方便。例如,MNIST dataset 通常会完全加载到内存中。这种方式在收敛方面也更可取,当单个图像差异很大时:两个训练图像,一个主要是白色,另一个主要是黑色,将有非常不同的均值。
Per image 当逐张或小批量加载图像时,例如从 TFRecord 加载图像时,规范化很方便。当数据集太大而无法放入内存时,它也是唯一可行的选择。在这种情况下,最好组织 input pipeline in tensorflow and transform the image tensors just like other tensors in the graph. I've seen pretty good accuracy with this normalization in CIFAR-10, so it's a viable way, despite the issues stated earlier. Also note that you can reduce the negative effect via batch normalization.
在为神经网络训练准备训练集时,我发现了两种可能的方法。
- 传统方法:在整个训练集上计算均值,并在发送到网络之前减去每个图像的固定均值。以类似的方式处理标准差。
- 我发现 tensorflow 提供了一个函数
tf.image.per_image_standardization
可以对 单个图像 . 进行归一化
不知哪种方式更合适?
两种方式都可以,选择主要取决于您读取数据的方式。
整个训练集 当您可以一次将整个数据集加载到一个 numpy 数组中时,规范化很方便。例如,MNIST dataset 通常会完全加载到内存中。这种方式在收敛方面也更可取,当单个图像差异很大时:两个训练图像,一个主要是白色,另一个主要是黑色,将有非常不同的均值。
Per image 当逐张或小批量加载图像时,例如从 TFRecord 加载图像时,规范化很方便。当数据集太大而无法放入内存时,它也是唯一可行的选择。在这种情况下,最好组织 input pipeline in tensorflow and transform the image tensors just like other tensors in the graph. I've seen pretty good accuracy with this normalization in CIFAR-10, so it's a viable way, despite the issues stated earlier. Also note that you can reduce the negative effect via batch normalization.