【发布时间】:2017-06-03 06:57:28
【问题描述】:
这是 Keras 中 inception v3 的预处理功能。它与其他模型的预处理完全不同。
def preprocess_input(x):
x /= 255.
x -= 0.5
x *= 2.
return x
1.为什么没有均值减法?
2。为什么没有RGB转BGR?
3。 [-1,1] 之间的映射对于这个模型是正常的吗?
这是Keras中VGG和ResNet的预处理功能:
def preprocess_input(x, data_format=None):
if data_format is None:
data_format = K.image_data_format()
assert data_format in {'channels_last', 'channels_first'}
if data_format == 'channels_first':
# 'RGB'->'BGR'
x = x[:, ::-1, :, :]
# Zero-center by mean pixel
x[:, 0, :, :] -= 103.939
x[:, 1, :, :] -= 116.779
x[:, 2, :, :] -= 123.68
else:
# 'RGB'->'BGR'
x = x[:, :, :, ::-1]
# Zero-center by mean pixel
x[:, :, :, 0] -= 103.939
x[:, :, :, 1] -= 116.779
x[:, :, :, 2] -= 123.68
return x
Caffe 模型也使用均值减法和 RGB 到 BGR。
【问题讨论】:
标签: deep-learning keras keras-2