Exercise 2 - alpaca_model - hint

can anyone pls help on where my mistake is ?
i did use Dense(1)(x) for the last output but still error as below


TypeError Traceback (most recent call last)
in
----> 1 model2 = alpaca_model(IMG_SIZE, data_augmentation)

in alpaca_model(image_shape, data_augmentation)
27
28 # data preprocessing using the same weights the model was trained on
—> 29 x = preprocess_input(x)
30
31 # set training to False to avoid keeping track of statistics in the batch norm layer

/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/applications/mobilenet_v2.py in preprocess_input(x, data_format)
500 @keras_export(‘keras.applications.mobilenet_v2.preprocess_input’)
501 def preprocess_input(x, data_format=None):
→ 502 return imagenet_utils.preprocess_input(x, data_format=data_format, mode=‘tf’)
503
504

/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/applications/imagenet_utils.py in preprocess_input(x, data_format, mode)
117 else:
118 return _preprocess_symbolic_input(
→ 119 x, data_format=data_format, mode=mode)
120
121

/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/applications/imagenet_utils.py in _preprocess_symbolic_input(x, data_format, mode)
261 “”"
262 if mode == ‘tf’:
→ 263 x /= 127.5
264 x -= 1.
265 return x

TypeError: unsupported operand type(s) for /=: ‘Sequential’ and ‘float’

Use a Dense() layer with 1 unit.

i did use Dense(1)(x) for the last output but still error as above. can anyone help to have a look?

Hey @Lucy_Hui ,

Did you send the correct input? You can use a print statement to check what input the model is receiving.

Hope the hint helps :wink:

HI Sorry
you mean my input is wrong?
i changed it to inputs = InputLayer() still wrong,
can you pls hint me what this mean?

create the input layer (Same as the imageNetv2 input size)

what is imageNetv2 ? and how can i correct input ?thanks

Hi @Lucy_Hui,

Could you state where you changed the inputs to InputLayer()? Currently your input is a model layer while the input is supposed to be an image. That is why it is giving errors.

ImageNetV2 is a dataset of images.

you said my input is wrong, so i changed input from preprocess_input(x) to InputLayer().
and now still didn’t pass, also i tried input= ImageNetV2 also wrong, if you can suggest more?

the hint said i need create a layer but you mentioned i need input a image , how can i input pls
thanks

Could you send me your code privately?
It would help me give a better answer :slight_smile:

Thanks