# Week2 Emoji\_v3a low test accuracy but passed the grader

**URL:** <https://community.deeplearning.ai/t/week2-emoji-v3a-low-test-accuracy-but-passed-the-grader/103405>\
**Category:** Sequence Models\
**Tags:** coursera-platform\
**Created:** [February 26, 2022, 2:27pm UTC](https://community.deeplearning.ai/t/week2-emoji-v3a-low-test-accuracy-but-passed-the-grader/103405 "2022-02-26T14:27:37Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![gbdantoni](https://avatars.discourse-cdn.com/v4/letter/g/e495f1/32.png) [@gbdantoni](https://community.deeplearning.ai/u/gbdantoni)\
**Post date:** [February 26, 2022, 2:27pm UTC](https://community.deeplearning.ai/t/week2-emoji-v3a-low-test-accuracy-but-passed-the-grader/103405/1 "2022-02-26T14:27:38Z")

</div>

My code for Emoji\_v3a passes all of the internal tests and shows high accuracy and low loss values when training the Emojify\_V2 model but consistently gets a test accuracy value around 0.5. I carefully went through my code to compare my outputs against the expected outputs but couldn’t find any problems so I submitted the assignment, hoping the grader would identify which section of my code was incorrect, but the grader gave me 100/100 and said all functions are correct. Should I really expect the test accuracy to be between 80% and 95% and if so, where should I look to see what’s wrong?

---

<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:** [February 27, 2022, 12:10am UTC](https://community.deeplearning.ai/t/week2-emoji-v3a-low-test-accuracy-but-passed-the-grader/103405/2 "2022-02-27T00:10:58Z")

</div>

I get 80% on the test set when I run my noteboook.

What loss and accuracy do you get from cell with the model.fit() results?

Please post the values from the last few iterations.

---

<div class="post-metadata">

**Author:** ![gbdantoni](https://avatars.discourse-cdn.com/v4/letter/g/e495f1/32.png) [@gbdantoni](https://community.deeplearning.ai/u/gbdantoni)\
**Post date:** [February 27, 2022, 12:27am UTC](https://community.deeplearning.ai/t/week2-emoji-v3a-low-test-accuracy-but-passed-the-grader/103405/3 "2022-02-27T00:27:20Z")

</div>

The final loss and accuracy are: 0.0644 and 0.9848.

 ![image](https://global.discourse-cdn.com/dlai/original/2X/f/f8deadf64b0f4a3f907c6ddeed07872ee66b60a1.png)

---

<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:** [February 27, 2022, 12:35am UTC](https://community.deeplearning.ai/t/week2-emoji-v3a-low-test-accuracy-but-passed-the-grader/103405/4 "2022-02-27T00:35:32Z")

</div>

Those are the training set results, they look fine.  
I’m not sure why you’d have that much lower accuracy on the test set.  
I’ll think about it for a bit, and reply again if I have any ideas.

---

<div class="post-metadata">

**Author:** ![Jiachen\_Sun](https://avatars.discourse-cdn.com/v4/letter/j/87869e/32.png) [@Jiachen\_Sun](https://community.deeplearning.ai/u/Jiachen_Sun)\
**Post date:** [July 7, 2022, 8:09pm UTC](https://community.deeplearning.ai/t/week2-emoji-v3a-low-test-accuracy-but-passed-the-grader/103405/5 "2022-07-07T20:09:33Z")

</div>

I got a 0.625 test accuracy, but training accuracy also looks totally fine.

---

<div class="post-metadata">

**Author:** ![xl0](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/xl0/32/21037_2.png) [@xl0](https://community.deeplearning.ai/u/xl0)\
**Post date:** [July 15, 2022, 12:40pm UTC](https://community.deeplearning.ai/t/week2-emoji-v3a-low-test-accuracy-but-passed-the-grader/103405/6 "2022-07-15T12:40:18Z")

</div>

Same issue here, test accuracy between 65% and 75%:

```auto
2/2 [==============================] - 0s 3ms/step - loss: 1.4789 - accuracy: 0.6607

Test accuracy = 0.6607142686843872

```

Train accuracy gets up to 100%.

The model passes both the test and the autograder, so I can assume it’s correct. I did set the embedding layer as non-trainable.

Any ideas on what could be wrong?

---

<div class="post-metadata">

**Author:** ![xl0](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/xl0/32/21037_2.png) [@xl0](https://community.deeplearning.ai/u/xl0)\
**Post date:** [July 15, 2022, 2:23pm UTC](https://community.deeplearning.ai/t/week2-emoji-v3a-low-test-accuracy-but-passed-the-grader/103405/7 "2022-07-15T14:23:29Z")

</div>

Found the issue - the test dataset CSV file has been mishandled in the past, and the strings contain \t (TAB character) at the end. The training set does not suffer from this issue.

I used .split(’ ') to separate the words, which meant the last word of the sentence had a \t stuck to it and was not in the dictionary. The solution is to always use .split() without argument, which strips whitespace by default.

With correctly split words, I’m getting 82% accuracy, which is within the expected range, but surprisingly, still below the much simpler average vector model.

---

<div class="post-metadata">

**Author:** ![anon76241992](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@anon76241992](https://community.deeplearning.ai/u/anon76241992)\
**Post date:** [October 14, 2023, 9:12am UTC](https://community.deeplearning.ai/t/week2-emoji-v3a-low-test-accuracy-but-passed-the-grader/103405/8 "2023-10-14T09:12:55Z")

</div>

I come here for the same problem. I got 78% for test accuracy. Maybe this is because overfitting due to the use of embeddings??

---

<div class="post-metadata">

**Author:** ![anon76241992](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@anon76241992](https://community.deeplearning.ai/u/anon76241992)\
**Post date:** [October 14, 2023, 9:20am UTC](https://community.deeplearning.ai/t/week2-emoji-v3a-low-test-accuracy-but-passed-the-grader/103405/9 "2023-10-14T09:20:48Z")

</div>

Okay, I just ran the notebook again and now I got 85% acc at test set. Maybe the model is facing a very high variance problem.

 ![image](https://global.discourse-cdn.com/dlai/original/3X/0/1/01ee4b412d4ec3852fef20f72a2f91d779503c01.png)
