Help on Transformers Architecture with TensorFlow (C5_W4_A1_Transformer)

Hi,

Appreciate if you could help me with this question.

In this programming assignment. I have passed Exercise 1-4, including Exercise 4 (Encoder layer). However I have struggled with Exercise 5 (Encoder) for a few days. The following are my codes:

Moderator Edit: Solution Code Removed

The following error message kept showing up after running the unit test:

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

Your code seems correct to me. Did you run the cell every time you make the changes? Try Kernel → Restart and then run all the cells from the top…

PS: Please note that sharing your code is not allowed. Next time, only share your full error…

Hello Zhang,

I am sorry Zhang, I misread your comment.

but your error logs tell you to check grader cell C4 as encoder output is incorrect and is not matching by value.

please note based on your codes shared, the code line for the below statement is incorrect in C5

Add the position encoding to embedding

you have added an extra code line with # which is not required

Kindly share the codes with either Saif or me for C4 grader cell too.

Regards
DP

1 Like

Hi Saif,

Thak you so much Saif for correcting me, I got confused with the learner’s first statement about C4 and missed seeing C5. But the error log shows his encoder cell C4 also might have a value error. Although his C5 codes are correct but he has added one extra code lines for positional encoding which needs to be removed.

Regards
DP

Yes, that user added some extra lines of code. Luckily, these lines are commented and has no effect on code but make the reading hard…

1 Like

Thank you Saif and DP.

I followed Saif’s instruction. Kernel → Restart and then run all the cells from the top. The problem is still there. C4 passed all the tests. The same error message showed up again for C5.

Please share grader cell C4 and C5 via personal DM to Saif or me.

We will have a look about where it went wrong. Don’t share your codes here. It is against community guidelines.

Click on my name and then message.

Regards
DP

Zhang

I told you share the codes via personal DM and not on the post. Click on my name, and then message to share the codes.

Please read the comments carefully. It is against community guidelines to share codes here in public post as Saif also had mentioned you the same thing.

Remove the codes

Sorry. I will try DM. Thanks

Delete your previous comment by clicking on the three dots on right bottom corner and then selecting delete option

Hello Zhang,

Indeed your Encoder grader cell had errors. Please read the comments in uppercase carefully and do the corrections.

Let us know once issue is resolved.

Regards
DP

Thanks DP! I am working on it.

Thanks DP and Saif! Problem solved. I have passed the program assignment.

1 Like

C. Hepp, Electronic Structure of the Silicon Vacancy
Color Center in Diamond, Ph.D. thesis, Saarland Uni-
versity (2014).

W. B. Gao, A. Imamoglu, H. Bernien, and R. Hanson,
Nat. Photonics 9, 363 (

C. Hepp, T. M¨uller, V. Waselowski, J. N. Becker, B. Pin-
gault, H. Sternschulte, D. Steinm¨uller-Nethl, A. Gali,
J. R. Maze, M. Atat¨ure, and C. Becher, Phys. Rev. Lett.
112, 036405 (2014