Error in happy_model

I am trying to execute the happy_model. I am getting the below error. Please help me in this regard. Thanks

{moderator edit - solution code removed}

The instructions assume that you’re going to use the “list of layers” method, not the .add method.
You only need a comma at the end of each line if you’re using the list of layers. So the commas should be removed if you’re using the .add method.

I think some of your layers may be the wrong type.

Some of the layers are specified as keras layers - but your ‘.add’ method is not using the correct keras syntax.

Hi Mosh,
Thank you for the reply. I am able clear that error but I am facing an error in the function convolutional_model. Can you please help in this regard.

{moderator edit - solution code removed}


ValueError Traceback (most recent call last)
in
----> 1 conv_model = convolutional_model((64, 64, 3))
2 conv_model.compile(optimizer=‘adam’,
3 loss=‘categorical_crossentropy’,
4 metrics=[‘accuracy’])
5 conv_model.summary()

in convolutional_model(input_shape)
24
25 ## RELU
—> 26 A1 = tf.keras.layers.ReLU()(Z1)
27 # A1 = None
28 ## MAXPOOL: window 8x8, stride 8, padding ‘SAME’

/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/engine/base_layer.py in call(self, *args, **kwargs)
983
984 with ops.enable_auto_cast_variables(self._compute_dtype_object):

ValueError: Attempt to convert a value (<tensorflow.python.keras.layers.convolutional.Conv2D object at 0x7f4419028710>) with an unsupported type (<class ‘tensorflow.python.keras.layers.convolutional.Conv2D’>) to a Tensor.

The problem is that you have defined the first Conv2D layer, but you have not actually invoked it with an input. So Z1 is the Conv2D function instead of an output tensor, which is what is expected by the later steps. Compare the first Conv2D line with some of your later ones, which are correct at least in that regard. I didn’t really check the parameters, but they do get the input tensor specified correctly on the later ones.