C5_W4_A1 exercise 4 "InvalidArgumentError"

I’m receiving an error of “InvalidArgumentError: Shapes of all inputs must match: values[0].shape = [1,3,4] != values[1].shape = [1,2,3,3] [Op:Pack] name: y”
@balaji.ambresh Thanks!

1 Like

Here are some hints:

  1. The call to self.mha has ignored the mask.
  2. Set return_attention_scores to a proper default. See this
  3. Pass training parameter to all layers whese applicable.
1 Like

That’s super helpful. But I still need help. I’ve applied Training=True to all layers that are applicable. But still receiving error message of “Wrong values when training=False”. @balaji.ambresh

training flag should not be hardcoded. See the parameters passed to the call function to set the value dynamically. This will ensure that test cases that expect weights not to change when training=False will pass.

I see. now it works!
but can you elaborate a bit on what training parameters do? or can you give an example of what training parameter would look like?

A layer can be used in one of 2 modes:

  1. Training mode (training=True): This is when the weights change during backward pass. When model.fit is invoked, the framework internally sets the layer to training mode.
  2. Inference mode (training=False): Layer weights don’t change in this mode. The intent is to use the model just make predictions based on user input.

Reference: call(self, *args, **kwargs)

I mean when we set training=training. What would input training parameters look like?

training is a boolean. See EncoderLayer_test defined in public_tests.py either via the jupyter interface or download the entire assignment and view the file.

A layer has weights & biases. These are collectively called as trainable parameters. You don’t have to worry about these since setting the training parameter will take care of backpropagation if required.

Oh Ok. Thank you for your help!