且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在微调预训练的模型时在Keras中预处理图像的正确方法是什么

更新时间:2023-12-02 21:56:34

始终使用 preprocess_input 函数。也就是说,对于 InceptionV3 keras.applications使用 keras.applications.inception_v3.preprocess_input 。 resnet50.preprocess_input 用于 ResNet50

Always use the preprocess_input function in the corresponding model-level module. That is, use keras.applications.inception_v3.preprocess_input for InceptionV3 and keras.applications.resnet50.preprocess_input for ResNet50.

模式参数指定训练原始模型时使用的预处理方法。 mode ='tf'表示预训练权重是从TF转换而来的,其中作者使用 [-1,1] ,c来训练模型。 code>输入范围。 mode ='caffe' mode ='torch'也是如此。

The mode argument specifies the preprocessing method used when training the original model. mode='tf' means that the pre-trained weights are converted from TF, where the authors trained model with [-1, 1] input range. So are mode='caffe' and mode='torch'.

应用程序的输入。*。preprocess_input 始终为RGB。如果模型期望输入BGR,则将在 preprocess_input 内部置换通道。

The input to applications.*.preprocess_input is always RGB. If a model expects BGR input, the channels will be permuted inside preprocess_input.

您提到的博客文章是在引入 keras.applications 模块之前发布的。我不建议将它用作 keras.applications 的转移学习的参考。也许***在 docs 中尝试这些示例。

The blog post you've mentioned was posted before the keras.applications module was introduced. I wouldn't recommend using it as a reference for transfer learning with keras.applications. Maybe it'll be better to try the examples in the docs instead.