I keep getting assertion error - Week 1 programming assignment 2

Test failed
Expected value

[‘ReLU’, (None, 64, 64, 8), 0]

does not match the input value:

[‘Activation’, (None, 64, 64, 8), 0]

Which function are you working on? ReLU is used a lot of places in that assignment.

Are you using the Keras function for ReLU?

I use this:


A1 = tf.keras.activations.relu(Z1)

I am working on this function convolutional_model(input_shape):

It seems to work after this assertion error though, when I do:
history = conv_model.fit(train_dataset, epochs=100, validation_data=test_dataset) .

But due to the assertion error I am not graded I think. So kindly let me know what to do ?

1 Like

You are using the Keras “Functional API” here. So it’s a little more complicated than the way you have done it. It’s a two step process:

First you invoke the ReLU layer to create the function you want and then you invoke it. The first step looks like this:


Then to invoke that you do this:

outputTensor = tfl.ReLU()(inputTensor)

Its from week 1’s programming exercise 2 “convolution model application”.
Yes, you are right, A1 = tf.keras.layers.ReLU()(Z1) did it. It works now.

I am still figuring out the sequential model. there was an assertion error but let me figure it out.

But thanks for the tip, it works now.

In the Sequential API case, you are not actually invoking the function because the inputs are “implicit”. You just instantiate the function to specify the parameter settings (step 1 of my previous description).

Ok understood. Thanks

Here’s another recent thread that describes the Functional API in a tiny bit more detail.

That’s the problem. You’re supposed to use the Keras functions for this exercise.

@venkat1 can you please help me. I have also the same query but I am not able to figure it out.

Did you read my earlier responses on this thread and follow the links? I think all the information is there to figure it out if you have the exact same mistake the @venkat1 had.

The problem is solved now. Thanks @paulinpaloalto

1 Like

That’s great! Thanks for confirming.