# C5W4A1 UNQ\_C5 Encoder - AssertionError: Wrong values case 1

**URL:** <https://community.deeplearning.ai/t/c5w4a1-unq-c5-encoder-assertionerror-wrong-values-case-1/35572>\
**Category:** Sequence Models\
**Tags:** coursera-platform\
**Created:** [September 10, 2021, 3:41pm UTC](https://community.deeplearning.ai/t/c5w4a1-unq-c5-encoder-assertionerror-wrong-values-case-1/35572 "2021-09-10T15:41:41Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jeff](https://avatars.discourse-cdn.com/v4/letter/j/e19b73/32.png) [@Jeff](https://community.deeplearning.ai/u/Jeff)\
**Post date:** [September 10, 2021, 3:41pm UTC](https://community.deeplearning.ai/t/c5w4a1-unq-c5-encoder-assertionerror-wrong-values-case-1/35572/1 "2021-09-10T15:41:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![TMosh](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/tmosh/32/9321_2.png) [@TMosh](https://community.deeplearning.ai/u/TMosh)\
**Post date:** [September 10, 2021, 4:13pm UTC](https://community.deeplearning.ai/t/c5w4a1-unq-c5-encoder-assertionerror-wrong-values-case-1/35572/2 "2021-09-10T16:13:31Z")

</div>

All that tells me is that there’s an error in your Encoder() function.

---

<div class="post-metadata">

**Author:** ![TMosh](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/tmosh/32/9321_2.png) [@TMosh](https://community.deeplearning.ai/u/TMosh)\
**Post date:** [September 10, 2021, 4:14pm UTC](https://community.deeplearning.ai/t/c5w4a1-unq-c5-encoder-assertionerror-wrong-values-case-1/35572/3 "2021-09-10T16:14:12Z")

</div>

You can look in the public\_tests.py file to see what “case 1” refers to.

---

<div class="post-metadata">

**Author:** ![Jeff](https://avatars.discourse-cdn.com/v4/letter/j/e19b73/32.png) [@Jeff](https://community.deeplearning.ai/u/Jeff)\
**Post date:** [September 10, 2021, 4:20pm UTC](https://community.deeplearning.ai/t/c5w4a1-unq-c5-encoder-assertionerror-wrong-values-case-1/35572/4 "2021-09-10T16:20:29Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![TMosh](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/tmosh/32/9321_2.png) [@TMosh](https://community.deeplearning.ai/u/TMosh)\
**Post date:** [September 10, 2021, 4:59pm UTC](https://community.deeplearning.ai/t/c5w4a1-unq-c5-encoder-assertionerror-wrong-values-case-1/35572/5 "2021-09-10T16:59:35Z")

</div>

(edited the text of my reply).

---

<div class="post-metadata">

**Author:** ![Jeff](https://avatars.discourse-cdn.com/v4/letter/j/e19b73/32.png) [@Jeff](https://community.deeplearning.ai/u/Jeff)\
**Post date:** [September 10, 2021, 6:18pm UTC](https://community.deeplearning.ai/t/c5w4a1-unq-c5-encoder-assertionerror-wrong-values-case-1/35572/6 "2021-09-10T18:18:33Z")

</div>

In scaling the embedding, i was used square root of seq\_len instead of the embedding\_dim.  
Thank you Tom 👍
