Error in the final programming exercise of transformers

AssertionError: Wrong values when training=True
This error is showing when running EncoderLayer_test(EncoderLayer)
My code is correct what to do ? Please help fast

I don’t think this thread belongs in the general discussion category. Please move it to the appropriate course category.

do you know how to solve this error?

I am not a mentor of this course, but generally, the test case might be failing due to a fault in your code.

@Mujassim_Jamal is correct. And specifically, it fails when tested with training = True.

Maybe this thread helps you.


values are wrong from skip connection I have checked the code nothing seems wrong what could be possible solution to correct code if its wrong ?

Maybe try cross-checking your code against the hints, if provided in the lab.

is there any way you can check my code ? I will post it here and delete it immediately ? Please

Please help me to solve this is there any way can i share my code with you?

As I already mentioned, I am not a mentor for this course, and posting code on forums is not allowed.

I hope the other mentors of this course, if they want to see your code, can ask you to send it privately.

Ok thank you for your help

This is my output:

self_mha_output:[[[ 0.2629684   0.5438655  -0.47695604  0.43180236]
  [ 0.27214473  0.5516315  -0.47251672  0.44105405]
  [ 0.2637157   0.5352751  -0.46818826  0.44008902]]]
skip_x_attention:[[[ 0.7840514  -0.9639456  -1.0145587   1.1944535 ]
  [-1.2134784   1.0835364  -0.7550787   0.885021  ]
  [ 0.76012594 -0.20960009 -1.545446    0.9949202 ]]]
ffn_output:[[[-0.40299335 -0.26304182  0.01199517  0.77515805]
  [ 0.11928089  0.02366283  0.21244505  0.6133719 ]
  [-0.47993705 -0.35966852  0.11620045  0.9476139 ]]]
ffn_output after dropout:[[[-0.44777042 -0.2922687   0.01332797  0.86128676]
  [ 0.13253433  0.02629204  0.23605007  0.6815244 ]
  [-0.5332634  -0.3996317   0.          1.0529044 ]]]
encoder_layer_out:[[[ 0.23017097 -0.9810039  -0.78707564  1.5379086 ]
  [-1.2280797   0.76477575 -0.7169284   1.1802323 ]
  [ 0.14880148 -0.4831803  -1.1908401   1.5252188 ]]]

Compare this with yours and see where your values are not matching with mines. That is the place to look out.

Best,
Saif.