Week 2 - assignement 1: convolutional block

Hello all,

I have a problem with the convolutional block. For me all looks right but I have an error. I checked the parameters for the different convolutional blocks. The input for the shortcut path is also correct!

The error I am recieving is the following:

“Wrong values when training=False.”

I would be happy if someone could help me.

Thank you in advance :slight_smile:

Valentina

2 Likes

Additionally:

I have submitted the assignement and I have 0/100 points, which just cannot be. The grader is saying:

Cell #5. Can’t compile the student’s code. Error: AssertionError(‘Wrong values when training=False.’)

Please help me.

Thanks,
Valentina

2 Likes

I have rebooted the assignement and still I have the same problem :frowning:

1 Like

Hi Valentina,

I would advise you to check your SHORTCUT PATH - specifically note the input value.

Hint: it should not be “X”.

Regards,
Sam

21 Likes

Hello Sam,

Thank you very much for your help.

My input for the shortcut is correct: X_shortcut.
I must have another problem/error.

Right now I cannot post my code but on Monday I will do. I would be happy if you could have a look at my code then.

Regards
Valentina

1 Like

Yeap, please share it here - I can quickly take a glance, then we can delete it once issue is resolved.

1 Like

I had the same error. check the kernel_size and strides values for all Conv2D as mentioned in the explanation part.

1 Like

Hello Sam,

I could solve the problem ! I had one activation (relu) too much.

Thank you all for your support.

Valentina

3 Likes

I also had the same error. In third main path, I used a Activation instead of BatchNorm. If someone gets the above error, please check “The details of the convolutional block” carefully.

2 Likes

Thanks, your hint solved my problem :))

1 Like

@dexcrew I too have the same error. I tried hard rectifying it but all in vain. I am posting my code here could you plz take a quick look and give me the hint to sort out the issue

MAIN PATH
# First component of main path glorot_uniform(seed=0)
X = Conv2D(filters = F1, kernel_size = (1,1), strides = (s, s), padding='valid', kernel_initializer = initializer(seed=0))(X)
X = BatchNormalization(axis = 3)(X, training = training)
X = Activation('relu')(X)

### START CODE HERE

## Second component of main path (≈3 lines)
X = Conv2D(filters = F2, kernel_size = (f,f), strides = (1, 1), padding='same', kernel_initializer =initializer(seed=0))(X)
X = BatchNormalization(axis = 3)(X, training = training)
X = Activation('relu')(X)

## Third component of main path (≈2 lines)
X = Conv2D(filters=F3, kernel_size=(1, 1), strides=(1, 1), padding='valid', kernel_initializer=initializer(seed=0))(X)
X = BatchNormalization(axis = 3)(X, training = training)

##### SHORTCUT PATH ##### (≈2 lines)
X_shortcut = Conv2D(filters = F3, kernel_size = (1,1), strides = (s,s), padding='valid', kernel_initializer =initializer(seed=0))(X)
X_shortcut = BatchNormalization(axis = 3)(X_shortcut, training = training)


# Final step: Add shortcut value to main path, and pass it through a RELU activation (≈2 lines)
X = Add()([X, X_shortcut])
X = Activation('relu')(X)
### END CODE HERE
1 Like

Our code is the same and I am having the same issue. Were you able to resolve it?

1 Like

Had the same issue. I believe the problem is that you are passing (X) to the Conv2D() function in the Shortcut Path. Instead you should be passing X_shortcut

2 Likes

Hi, Moneet,

Posting the code on Discourse is a violation. I hope that your query is resolved, and if not, the notebook has been updated and you need to get the latest version. Thanks!

1 Like

I am having exactly the same issue, but I checked everything and all seems to be correct. I don´t find what the mistake is. I have spent literally days trying to figure out what the error is but don´t find it.

1 Like

Welcome to the community !

If you have “exactly the same issue”, then, you have the answer in here already. For example, sesteban provides the fix for Moneet_Mohan_devadig’s case.

If that is not the case, I recommend you to create a new thread. Then, we can focus on your case.

1 Like

I’m also having the very same problem as everyone on this thread has had. I’ve carefully gone through the various fixes people have mentioned, but I still get the “AssertionError: Wrong values when training=False.” Is there another approach that might work?

1 Like

This is to show how this convolutional block is used in Resnet50.

This chart does not include BatchNorm and Activation.

This is quite similar to the identity block (Exercise 1), but one big difference is a convolutional layer in the short cut side. In the main path, “X” is passed throughout the layers. But, short cut side is not. Please check step by step with the chart above.

1 Like

Hi, Nobu. How do you generate the graph above? I’ve gone through my code as carefully as I can. I’ve changed X to X.shortcut, rechecked my activation functions (as well as when to use them), and gone through all kernel and strides variables as provided in the instructions. In fact, those instructions are so clear that I’m surprised I am getting the error at all.

1 Like

Hi, Nobu,

I found the source of error. But I’d still like to know how to generate the graph that you posted, as it would be a good guide to analyze future models.

1 Like