C5_W4_A1_Q7 - Wrong values in outd

Hi,

I’m on the final assignment and I’m trying to figure out what is wrong with my submission. Any help would be appreciated.

The unit tests for exercises 1 through 6 all passed. However, when I get to exercise 7 (Decoder), it produces the following error:

AssertionError                            Traceback (most recent call last)
<ipython-input-31-dd4b65c051b4> in <module>
      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(outd), "Wrong type for outd. It must be a dict"
    222     assert np.allclose(tf.shape(outd), tf.shape(encoderq_output)), f"Wrong shape. We expected { tf.shape(encoderq_output)}"
--> 223     assert np.allclose(outd[1, 1], [-0.2715261, -0.5606001, -0.861783, 1.69390933]), "Wrong values in outd"
    224 
    225     keys = list(att_weights.keys())

AssertionError: Wrong values in outd

Exercise 8 is failing as well (presumably because it relies on the Decoder from exercise 7). If I try to submit the assignment, I get 0/100 (even though the unit tests for exercises 1-6 passed), with the following grader output on Exercise 8:

Cell #22. Can't compile the student's code. Error: AssertionError('Wrong values in outd')

I’m not sure if I’m allowed to post my code for review, but this is the value I get for outd[1,1] when I plug in the inputs from the exercise 7 unit test:

<tf.Tensor: shape=(4,), dtype=float32, numpy=array([-0.27533835, -1.0624421 , -0.30593687,  1.6437175 ], dtype=float32)>

As you can see, the first and fourth numbers are kind of close. The two middle numbers are way off.

I have tried rebooting the kernel as well as refreshing my workspace.

Can anyone give me any guidance for how to diagnose what is going on?

Thanks.

Basics first:

  • Did your DecoderLayer() pass all its unit tests?
  • Did you modify any of the code in the constructor part of the Decoder() class?
  • In Decoder(), did you use “training=training” in the dropout layer?

Hi @TMosh, thanks for getting back to me.

Yes, DecoderLayer_test(DecoderLayer, create_look_ahead_mask) shows “All tests passed” when I run it.

No.

Yes, I’ve got training=training as the second argument.

{edited my reply for brevity}

Recap for those who find this thread later:
The problem was a typo in the Decoder() class code.

Hey. I am still getting this issue. What type in the Decoder() class?

Please do not post your code on the Forum. That breaks the course Honor Code.