# C3W2\_Assignment Error

**URL:** <https://community.deeplearning.ai/t/c3w2-assignment-error/744974>\
**Category:** Natural Language Processing in TensorFlow\
**Tags:** ai-discussions, week-module-2, project\
**Created:** [January 3, 2025, 12:22am UTC](https://community.deeplearning.ai/t/c3w2-assignment-error/744974 "2025-01-03T00:22:45Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![JoudSaqer](https://avatars.discourse-cdn.com/v4/letter/j/e9bcb4/32.png) [@JoudSaqer](https://community.deeplearning.ai/u/JoudSaqer)\
**Post date:** [January 3, 2025, 12:22am UTC](https://community.deeplearning.ai/t/c3w2-assignment-error/744974/1 "2025-01-03T00:22:45Z")

</div>

Hello,  
I’m working on the assignment, but there is an error occurring.

This is the output of the fit\_label\_encoder function :

 ![image](https://global.discourse-cdn.com/dlai/original/3X/b/a/bada7e0e15f85ce2f0d55668985227a388abbc19.png)

And the test has passed :

 ![image](https://global.discourse-cdn.com/dlai/original/3X/3/3/334e0e958534fd9ff9bf9820caea3182f3b147a8.png)

However, when I try to complete Exercise 4: preprocess\_dataset, there is an error. Here is the output:

 ![image](https://global.discourse-cdn.com/dlai/original/3X/5/b/5b993571596715525870964ccbab2838bf886dcf.png)

And here is the error message:

 ![image](https://global.discourse-cdn.com/dlai/original/3X/8/f/8fb2a3c7bd3873748f5337ab5f69101f7c8d59a0.png)  
 ![image](https://global.discourse-cdn.com/dlai/original/3X/d/b/db32e79cc977cb6d9b4b6794f46832468aac7319.png)

I hope someone can help me. Thank you very much.

---

<div class="post-metadata">

**Author:** ![Deepti\_Prasad](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/deepti_prasad/32/165831_2.png) [@Deepti\_Prasad](https://community.deeplearning.ai/u/Deepti_Prasad)\
**Post date:** [January 3, 2025, 4:26am UTC](https://community.deeplearning.ai/t/c3w2-assignment-error/744974/2 "2025-01-03T04:26:20Z")

</div>

refer this

> [@C3W2 Expected output](https://community.deeplearning.ai/t/c3w2-expected-output/686651/11):
>
> In the preprocess data, basically there are 3 call arguments already assigned for this grade cell. one is dataset for you to preprocess next text\_vectorizer which is function recall to convert your text data into vector and lastly label\_encoder which you recalled in the previous grade cell will be used to encode data labels here in this cell, preparing your preprocess data to be model trained. You need to define this in single code line using map keys( ) to the argument dataset. Hope this r…

you are probably dividing dataset step into two steps where you are recalling each set twice, dataset need to be recalled in one single step

refer the comment link which explains how to write the code

---

<div class="post-metadata">

**Author:** ![JoudSaqer](https://avatars.discourse-cdn.com/v4/letter/j/e9bcb4/32.png) [@JoudSaqer](https://community.deeplearning.ai/u/JoudSaqer)\
**Post date:** [January 4, 2025, 7:05pm UTC](https://community.deeplearning.ai/t/c3w2-assignment-error/744974/3 "2025-01-04T19:05:38Z")

</div>

> [@Deepti\_Prasad](#):
>
> you are probably dividing dataset step into two steps where you are recalling each set twice, dataset need to be recalled in one single step

@Deepti_Prasad  
Thanks, I converted the dataset sentences to sequences and encoded the text labels in a single step.  
But I found that the label and text were reversed (the shape wasn’t as expected), so I corrected it. However, something strange is happening—there’s an error in one cell, but the test is still passing.

I will show you from " Exercise 3: fit\_label\_encoder" step :

 ![image](https://global.discourse-cdn.com/dlai/original/3X/2/0/20952f0dcb2a1015c68dc0ef2a32719be41c4f21.png)

“Exercise 4: preprocess\_dataset” Step, where I correct the shape of the data:

 ![image](https://global.discourse-cdn.com/dlai/original/3X/c/8/c805ffceeb789b7d038838407d18039e2da9e85f.png)

 ![image](https://global.discourse-cdn.com/dlai/original/3X/a/8/a86231ca9f8a2e5dbd7807d76dacbfa782e32e28.png)

 ![image](https://global.discourse-cdn.com/dlai/original/3X/3/6/36630ca39472000cac75673842835d6d384d93fb.png)

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

Thank you very much for your help.

---

<div class="post-metadata">

**Author:** ![Deepti\_Prasad](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/deepti_prasad/32/165831_2.png) [@Deepti\_Prasad](https://community.deeplearning.ai/u/Deepti_Prasad)\
**Post date:** [January 4, 2025, 9:30pm UTC](https://community.deeplearning.ai/t/c3w2-assignment-error/744974/4 "2025-01-04T21:30:01Z")

</div>

> [@JoudSaqer](#):
>
> converted the dataset sentences to sequences and encoded the text labels in a single step.

if you have done dataset step in 1 step and still it is throwing error, then one has to go back to previous exercise where you have passed test, you can DM screenshot of the codes.

---

<div class="post-metadata">

**Author:** ![JoudSaqer](https://avatars.discourse-cdn.com/v4/letter/j/e9bcb4/32.png) [@JoudSaqer](https://community.deeplearning.ai/u/JoudSaqer)\
**Post date:** [January 5, 2025, 3:48pm UTC](https://community.deeplearning.ai/t/c3w2-assignment-error/744974/6 "2025-01-05T15:48:44Z")

</div>

> [@Deepti\_Prasad](#):
>
> issue is you mention that extra label, text after lambda(you don’t require to mention label and text and again use the function recall to text and labels

@Deepti_Prasad  
I’m sorry, can you explain this part " issue is you mention that extra label, text after lambda(you don’t require to mention label and text and again use the function recall to text and labels".

---

<div class="post-metadata">

**Author:** ![Deepti\_Prasad](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/deepti_prasad/32/165831_2.png) [@Deepti\_Prasad](https://community.deeplearning.ai/u/Deepti_Prasad)\
**Post date:** [January 5, 2025, 4:24pm UTC](https://community.deeplearning.ai/t/c3w2-assignment-error/744974/7 "2025-01-05T16:24:38Z")

</div>

sorry @JoudSaqer

your dataset codes are right, I mixed with other learner’s post query.

but in the fit\_label encoder for code line

join the two label datasets

You used incorrect function to concatenate the training and validation labels.

you were suppose to use train\_labels argument to concatenate to validation\_labels and tf.data.Dataset, that multiplied the number of dataset in your case which was more than what was required, hence threw that error.
