Deep learning Keras中inception v3的预处理功能
这是Keras中inception v3的预处理功能。它与其他模型的预处理完全不同Deep learning Keras中inception v3的预处理功能,deep-learning,keras,keras-2,Deep Learning,Keras,Keras 2,这是Keras中inception v3的预处理功能。它与其他模型的预处理完全不同 def preprocess_input(x): x /= 255. x -= 0.5 x *= 2. return x 1。为什么没有平均减法? 2。为什么BGR没有RGB? 3。[-1,1]之间的映射对于该模型是正常的? 这是Keras中VGG和ResNet的预处理功能: def preprocess_input(x, data_format=None): if da
def preprocess_input(x):
x /= 255.
x -= 0.5
x *= 2.
return x
1。为什么没有平均减法?
2。为什么BGR没有RGB?
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