# C4\_W1\_Q6 Output close to expected output but wrong

**URL:** <https://community.deeplearning.ai/t/c4-w1-q6-output-close-to-expected-output-but-wrong/301621>\
**Category:** NLP with Attention Models\
**Tags:** week-module-1\
**Created:** [April 2, 2023, 1:27pm UTC](https://community.deeplearning.ai/t/c4-w1-q6-output-close-to-expected-output-but-wrong/301621 "2023-04-02T13:27:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Frank\_wu1](https://avatars.discourse-cdn.com/v4/letter/f/3ab097/32.png) [@Frank\_wu1](https://community.deeplearning.ai/u/Frank_wu1)\
**Post date:** [April 2, 2023, 1:27pm UTC](https://community.deeplearning.ai/t/c4-w1-q6-output-close-to-expected-output-but-wrong/301621/1 "2023-04-02T13:27:34Z")

</div>

I’m stuck here for a few hours. No matter what I do, the output is still a few digits different from the expected output. What is wrong here, please help. I attached the error message below

* * *

AssertionError Traceback (most recent call last)  
 in   
1 # UNIT TEST  
2 # test\_next\_symbol  
----\> 3 w1\_unittest.test\_next\_symbol(next\_symbol, NMTAttn)

~/work/w1\_unittest.py in test\_next\_symbol(target, model)  
557 next\_de\_tokens = target(the\_model, tokens\_en, [18477], 0.0)  
558 # print(‘next\_de\_tokens’, next\_de\_tokens)  
 → 559 assert np.allclose([next\_de\_tokens[0], next\_de\_tokens[1]], [7283, -9.929085731506348]), f"Expected output: [{7283}, {-9.929085731506348}], your output: [{next\_de\_tokens[0]}, {next\_de\_tokens[1]}]"  
560  
561 print(“\033[92m All tests passed”)

AssertionError: Expected output: [7283, -9.929085731506348], your output: [7283, -9.819931983947754]

---

<div class="post-metadata">

**Author:** ![arvyzukai](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/arvyzukai/32/165165_2.png) [@arvyzukai](https://community.deeplearning.ai/u/arvyzukai)\
**Post date:** [April 2, 2023, 1:42pm UTC](https://community.deeplearning.ai/t/c4-w1-q6-output-close-to-expected-output-but-wrong/301621/2 "2023-04-02T13:42:32Z")

</div>

Hi @Frank_wu1

Most common mistake is using global variable `model` instead of the passed parameter `NMTAttn`.

Could that be your problem?

---

<div class="post-metadata">

**Author:** ![Frank\_wu1](https://avatars.discourse-cdn.com/v4/letter/f/3ab097/32.png) [@Frank\_wu1](https://community.deeplearning.ai/u/Frank_wu1)\
**Post date:** [April 2, 2023, 1:59pm UTC](https://community.deeplearning.ai/t/c4-w1-q6-output-close-to-expected-output-but-wrong/301621/3 "2023-04-02T13:59:03Z")

</div>

No, it was not my problem.

---

<div class="post-metadata">

**Author:** ![arvyzukai](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/arvyzukai/32/165165_2.png) [@arvyzukai](https://community.deeplearning.ai/u/arvyzukai)\
**Post date:** [April 2, 2023, 2:08pm UTC](https://community.deeplearning.ai/t/c4-w1-q6-output-close-to-expected-output-but-wrong/301621/4 "2023-04-02T14:08:06Z")

</div>

You can private message me (by clicking on my nickname) with [your notebook](https://www.coursera.org/learn/probabilistic-models-in-nlp/supplement/NdPJd/how-to-download-your-notebook) attached and I can try to help.

---

<div class="post-metadata">

**Author:** ![EdmondChan](https://avatars.discourse-cdn.com/v4/letter/e/f6c823/32.png) [@EdmondChan](https://community.deeplearning.ai/u/EdmondChan)\
**Post date:** [April 2, 2023, 3:22pm UTC](https://community.deeplearning.ai/t/c4-w1-q6-output-close-to-expected-output-but-wrong/301621/5 "2023-04-02T15:22:01Z")

</div>

Hi @arvyzukai , I get a similar situation, the output is slight different as below:  
AssertionError: Expected output: [7283, -9.929085731506348], your output: [7283, -9.864036560058594]… I just message you with my lap ID. Many thanks as well.

---

<div class="post-metadata">

**Author:** ![arvyzukai](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/arvyzukai/32/165165_2.png) [@arvyzukai](https://community.deeplearning.ai/u/arvyzukai)\
**Post date:** [April 3, 2023, 5:40am UTC](https://community.deeplearning.ai/t/c4-w1-q6-output-close-to-expected-output-but-wrong/301621/6 "2023-04-03T05:40:52Z")

</div>

Hi @EdmondChan

Mentors cannot access your learners’ notebooks by IDs (only staff members can). Before you private message me your notebook, [please check these cases](https://community.deeplearning.ai/search?q=7283%2C%20-9.929085731506348).
