CNN- Week 2 Assignment 1

I am getting the following error and i cannot figure out what is wrong with my code.

AssertionError: Wrong values when training=True.

For the second component of main path, I’ve got the following values: filter = F2, kernel size = f, stride =1, padding =same. batch norm on axis 3 and relu applied.
For third component, filter = F3, kernel size = 1, stride =1, padding =valid. batch norm on axis 3, no relu
For shortcut component, filter =F3, kernel size = 1, stride = s, padding = valid. batch norm on axis 3, no relu
The conv2d and batch norm is also applied to X_shortcut instead.

not sure what i am doing wrong. any help appreciated. thanks

Is this identity block or convolutional block code error?

please mention training=training for training to be true.

also if for convolution block, make sure in the second line of code for X_shortcut, you have recalled x as x but you need to recalled x as X_shortcut for instead of only (x)


this is the convolutional block. training is not defined anywhere in the code block, not sure where to insert training = training

the code given to me at the start of the code block was:

def convolutional_block(X, f, filters, s = 2, initializer=glorot_uniform): “”"
Implementation of the convolutional block as defined in Figure 4

X -- input tensor of shape (m, n_H_prev, n_W_prev, n_C_prev)
f -- integer, specifying the shape of the middle CONV's window for the main path
filters -- python list of integers, defining the number of filters in the CONV layers of the main path
s -- Integer, specifying the stride to be used
training -- True: Behave in training mode
            False: Behave in inference mode
initializer -- to set up the initial weights of a layer. Equals to Glorot uniform initializer, 
               also called Xavier uniform initializer.

X -- output of the convolutional block, tensor of shape (m, n_H, n_W, n_C)

i see that training is not included as an argument in the function. do i need to amend the function itself to include training?

Did you read this instruction before the grader cell for convolutional block

If training is set to False, its weights are not updated with the new examples. I.e when the model is used in prediction mode.

See this image

So you understand where all you need to include training=training

Same goes for the identity block as it includes the same instructions

Hi @sy_y,

Some changes have been made in the assignment recently, one of the major change being that the “training” parameter has been removed from Ex 1 and Ex 2

The code you shared above, the “training” parameter was left by mistake in the doc string of Ex 2. I apologise for the confusion it must have caused.

Also, ignore the screenshot @Deepti_Prasad shared above, as it is taken from the old version of the assignment.

I have just pushed a new update to this assignment (removing the “training” left in the doc string), this should provide you with the latest assignment version. Please work on that. Your previous solutions will still be valid as long as they don’t include the training parameter.

Even after this update, if find you still have the assignment version with training in the parameters for Ex 1 and Ex 2, please follow the instructions provided in order to get the latest assignment version.

Please let me know if you’d need any help,

@Deepti_Prasad, please take note of the changes that have been made.

thank you Mubsi and Deepti

Thank you Mubsi for the update.

So has your issue been resolved? if not you can share that part of the code via personal DM, to have a look where you might be going wrong

yes it is resolved. have submitted the assignment

@sy_y Can you share what you done?

I am having the same error on the block code and dont know what i am missing out.

The first assigment was ok without especifing any training parameters.

Share your error log, yes these both block will pass without training parameters in the updated assignment.

You should make sure you used the correct kernel parameter mentioned in both the blocks. Try to refer the instructions mentioned before these block. Remember you identity block codes is dependent on convolution block.