Week 4 - decoder Exercise 7

I have completed the decoderLayer and all tests passed.

However, I got this error for ### Exercise 7 - Decoder

AssertionError Traceback (most recent call last)
in
1 # UNIT TEST
----> 2 Decoder_test(Decoder, create_look_ahead_mask, create_padding_mask)

~/work/W4A1/public_tests.py in Decoder_test(target, create_look_ahead_mask, create_padding_mask)
221 assert tf.is_tensor(x), “Wrong type for x. It must be a dict”
222 assert np.allclose(tf.shape(x), tf.shape(encoderq_output)), f"Wrong shape. We expected { tf.shape(encoderq_output)}"
→ 223 assert np.allclose(x[1, 1], [-0.2715261, -0.5606001, -0.861783, 1.69390933]), “Wrong values in x”
224
225 keys = list(attention_weights.keys())

AssertionError: Wrong values in x

It seems very straightforward, so I have no idea how to look for the problem. What is the hard part that is likely to miss here?

Passing the tests for DecoderLayer() does not prove your code is perfect.

So I recommend you go over your DecoderLayer() code in detail and be sure you’ve followed all of the guidance in the notebook.

Particularly: watch where you use training=training. This is a common issue.

Incorrect use of training=training can also cause issues in Decoder()

Thanks for the hint. I would never have thought the problem is in the decoderLayer.

I used training= 3 times. Two times I set it to be True as I see # Dropout will be applied during training. The last time I set it to =training as suggested? Does this seem to be correct?

I set them all equal to train and it worked.

Thanks so much

In DecoderLayer(), you only use training=training once.