0

Edit: Solved. Spelling mistake, see first comment


  • I use a MobileNetV2 pretrained model in Keras2/TF2
    • My images are scaled to 224x224
    • I set the model input shape: input_shape=(224,224,3)

Later I use ImageGenerator to create the images. Here I set

  • data_format='channels_last'

as the model needs the channels at position 2 (0,1,2).

then in flow_from directory I set

  • target_size=[224,224]

When I then fit the model, I receive this error:

ValueError: Error when checking input: expected input_8 to have shape (224, 224, 3) but got array with shape (244, 244, 3)


Could it be that using channels_last in the Generator options lets the target in flow_from_directory be identify the dimensions wrongly as channel?

Or checking the error traceback extract_tensors_from_dataset=True reads the dimensions from the file rather than my given input_shape. In the (keras1) manual it reads :

...you can also omit this option if you would like to infer input_shape from an input_tensor. If you choose to include both input_tensor and input_shape then input_shape will be used if they match, if the shapes do not match then we will throw an error. E.g. (160, 160, 3) would be one valid value...

For me it looks like it takes the input_shape from the tensor, and then throws an error as the shape does not match...which it actually does.

also input_tensor is default None and I did not change it.

Does anyone know what is going wrong here?

Thanks

Florida Man
  • 2,021
  • 3
  • 25
  • 43

0 Answers0