Initially the model gave this warning:
WARNING:tensorflow:Model was constructed with shape (None, 160, 160, 3) for input Tensor(“input_2:0”, shape=(None, 160, 160, 3), dtype=float32), but it was called on an input with incompatible shape (None, 160, 160).
The model run ended with this error:
ValueError: Input 0 of layer Conv1_pad is incompatible with the layer: expected ndim=4, found ndim=3. Full shape received: [None, 160, 160]
The following hit the error:
34 # set training to False to avoid keeping track of statistics in the batch norm layer
—> 35 x = base_model(x, training=False)
Overall, my code looks like this:
(Solution code removed by staff)
Hey @SoumyaJRC, you are not calling the correct data augmentation function, nor passing it any input. And secondly, by the time you are doing your preprocessing, you inputs are already augmented, so why would you want to pass it the original inputs ? ← hint.
Hope this helps.
I’m removing your solution code as it is against the honour code to share it publicly. Especially also now that I have answered your query.
Thanks for your reply …
However, I have still faced the same error with input shapes even after modifying the data augmentation and passing the augmented inputs to the preprocessing step:
x = data_augmentation(tf.expand_dims(inputs, 0)) # for expanding the dim into a vector
x = preprocess_input(x) # to transform the pixels within (1-,1)
x = base_model(x, training=False) # transforming the preprocessed data through the base_model
WARNING:tensorflow:Model was constructed with shape (None, 160, 160, 3) for input Tensor(“input_14:0”, shape=(None, 160, 160, 3), dtype=float32), but it was called on an input with incompatible shape (1, None, 160, 160).
—> 35 x = base_model(x, training=False)
ValueError: Input 0 of layer Conv1 is incompatible with the layer: expected axis -1 of input shape to have value 3 but received input with shape [1, None, 161, 160]
Hey @SoumyaJRC. This incorrect. It is not as complicated as you are making it. You have to pass in a simple parameter. The name of it is given in the code comment above the variable.
I am trying to pass input_shape as the argument in the data_augmentation function but I’m getting a ton of errors such as:
WARNING:tensorflow:Layers in a Sequential model should only have a single input tensor, but we receive a <class ‘tuple’> input: (<tf.Tensor: shape=(), dtype=int32, numpy=160>, <tf.Tensor: shape=(), dtype=int32, numpy=160>)
Consider rewriting this model with the Functional API.
Shape () must have rank at least 3
‘image’ (shape ()) must be at least three-dimensional.
Which code comment is the name of the variable we have to pass? The code comment above the data_augmentation function only says “# apply data augmentation to the inputs”
I get the error “Input 0 of layer sequential_1 is incompatible with the layer: expected ndim=4, found ndim=3. Full shape received: [None, 160, 160]” so clearly passing “inputs” into the data_augmentation function is incorrect