0
votes

In Doc of tensorflow 2, it's said to use a pretrained resnet model, we should first input our image tensor into a specific preprocess_input layer. And I noticed this preprocess layer only accept tensors with value in range(0-255). Is that mean, the pre-trained weights are trained with image that have value in range(0-255)?

My another question is, when I check the source code in github, the preprocess_input layer works only in caffee mode, where the input tensors are only zero-centered with 3 values for 3 channels and aren't scaled into range of [0,1]. Should I rescale the ouput of preprocess layer before put the tensors into pretrained resnet model? And why it is in caffee mode?

Some definitions in tensorflow doc:

  • preprocess layer for resnet
    tf.keras.applications.resnet.preprocess_input(
        x, data_format=None
    )

    x: A floating point numpy.array or a tf.Tensor, 3D or 4D with 3 color channels, with values in the range [0, 255].
  • requirement to use preprocess layer in 1
Note: each Keras Application expects a specific kind of input preprocessing. For ResNet, call tf.keras.applications.resnet.preprocess_input on your inputs before passing them to the model.

Thanks

Does this answer your question? preprocess_input() method in keras - M.Innat
@M.Innat actually not, what I want to know is that why the preprocess layer use caffee mode, and should I do an extra rescaling step to change the value range to (0~1 or -1~1) between the specific preprocess layer and the resnet model? - Kanda Wa