C5W4A1: Error with EncoderLayer - AssertionError: Wrong values when training=True

Hello team,

I have been struggling for over several hours to get rid of the error in subject, with implementation of “EncoderLayer”. I have followed everything as per the instructions, as follows.

  1. Applied Self attention using self.mha - arguments (mentor edit: removed)
  2. Applied layer norm for above output; self.layernorm1 with args (mentor edit: removed)
  3. Passed above output to Feed forward neural network - self.ffn with args (mentor edit: removed)
  4. Applied drop out layer on above output. self.dropout_ffn with args (mentor edit: removed)
  5. Applied layer norm to the sum of above output and MHA. self.layernorm2 with args (mentor edit: removed)

Is there anything I am missing, kindly advise please. Below is the error that I get with the Unit Test(EncoderLayer_test).

AssertionError Traceback (most recent call last)
in
1 # UNIT TEST
----> 2 EncoderLayer_test(EncoderLayer)

~/work/W4A1/public_tests.py in EncoderLayer_test(target)
92 [[ 0.23017104, -0.98100424, -0.78707516, 1.5379084 ],
93 [-1.2280797 , 0.76477575, -0.7169283 , 1.1802323 ],
—> 94 [ 0.14880152, -0.48318022, -1.1908402 , 1.5252188 ]]), “Wrong values when training=True”
95
96 encoded = encoder_layer1(q, False, np.array([[1, 1, 0]]))

AssertionError: Wrong values when training=True

Never mind, I fixed the issue and got all the tests to pass. Earlier, I was not passing the mask parameter as the 4th parameter after query, key, value. I have added it now and removed the Training as the final argument.

1 Like

Even though there were mentor edits to the initial post, I found it very useful in working through this function myself. Thank you for your post and follow up comment.

1 Like

Same here