Jeff
September 10, 2021, 3:41pm
1
Hello everyone.
I have a mistake I can’t get out of. Could you help me to solve the problem?
Thanks in advance,
Jeff
AssertionError Traceback (most recent call last)
in
1 # UNIT TEST
----> 2 Encoder_test(Encoder)
~/work/W4A1/public_tests.py in Encoder_test(target)
124 [[-0.4612937 , 1.0697356 , -1.4127715 , 0.8043293 ],
125 [ 0.27027237, 0.28793618, -1.6370889 , 1.0788803 ],
→ 126 [ 1.2370994 , -1.0687275 , -0.8945037 , 0.7261319 ]]]), “Wrong values case 1”
127
128 encoderq_output = encoderq(x, True, np.array([[[[1., 1., 1.]]], [[[1., 1., 0.]]]]))
AssertionError: Wrong values case 1
TMosh
September 10, 2021, 4:13pm
2
All that tells me is that there’s an error in your Encoder() function.
TMosh
September 10, 2021, 4:14pm
3
You can look in the public_tests.py file to see what “case 1” refers to.
Jeff
September 10, 2021, 4:20pm
4
I was looking through public_tests.py. I have values that are very close but not exactly what is expected.
The error is in the call method of the encoder class, but I can’t find it !
Expected values :
assert np.allclose(encoderq_output.numpy(),
[[[-0.6906098 , 1.0988709 , -1.260586 , 0.85232526],
[ 0.7319228 , -0.3826024 , -1.4507656 , 1.1014453 ],
[ 1.0995713 , -1.1686686 , -0.80888665, 0.8779839 ]],
[[-0.4612937 , 1.0697356 , -1.4127715 , 0.8043293 ],
[ 0.27027237, 0.28793618, -1.6370889 , 1.0788803 ],
[ 1.2370994 , -1.0687275 , -0.8945037 , 0.7261319 ]]]), “Wrong values case 1”
Values obtained :
encoderq_output tf.Tensor(
[[[-0.6935428 1.1062188 -1.2575572 0.84488106]
[ 0.6917727 -0.37568048 -1.4484637 1.1323714 ]
[ 1.0744427 -1.1552584 -0.8278322 0.90864795]]
[[-0.46793145 1.0611441 -1.4099474 0.8167349 ]
[ 0.257472 0.30206454 -1.6373252 1.0777888 ]
[ 1.2434567 -1.0696429 -0.89144766 0.7176338 ]]], shape=(2, 3, 4), dtype=float32)
TMosh
September 10, 2021, 4:59pm
5
(edited the text of my reply).
Jeff
September 10, 2021, 6:18pm
6
In scaling the embedding, i was used square root of seq_len instead of the embedding_dim.
Thank you Tom
1 Like