# In C3W2\_Assignment, is the data possibly broken?

**URL:** <https://community.deeplearning.ai/t/in-c3w2-assignment-is-the-data-possibly-broken/772150>\
**Category:** Natural Language Processing in TensorFlow\
**Tags:** week-module-2\
**Created:** [February 18, 2025, 7:26am UTC](https://community.deeplearning.ai/t/in-c3w2-assignment-is-the-data-possibly-broken/772150 "2025-02-18T07:26:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![CyberViking](https://avatars.discourse-cdn.com/v4/letter/c/aeb1de/32.png) [@CyberViking](https://community.deeplearning.ai/u/CyberViking)\
**Post date:** [February 18, 2025, 7:26am UTC](https://community.deeplearning.ai/t/in-c3w2-assignment-is-the-data-possibly-broken/772150/1 "2025-02-18T07:26:18Z")

</div>

When I run exercise 3 I get a bad output

Unique labels: [‘sport’, ‘business’, ‘politics’, ‘entertainment’, ‘tech’, 'kennedy questions trust of blair lib dem leader charles kennedy has said voters now have a fundamental lack of trust of tony blair as prime minister. he said backing his … HUGE TEXT BLOB

But it passes all the unit tests.

When I get to Exercise 5 I again pass all the unit tests, but when I go to fit it crashes with

Received a label value of 438 which is outside the valid range of [0, 5). Label values: 281 311 366 145 121 64 438 326 185 49 391 370 15 347 138 51 314 105 373 158 208 358 111 99 339 240 365 332 352 302 9 96  
[[{{node compile\_loss/sparse\_categorical\_crossentropy/SparseSoftmaxCrossEntropyWithLogits/SparseSoftmaxCrossEntropyWithLogits}}]] [Op:\_\_inference\_one\_step\_on\_iterator\_853089]

Since I’m passing the unit tests I think the data must be missing a comma or newline somewhere?

---

<div class="post-metadata">

**Author:** ![gent.spah](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/gent.spah/32/136423_2.png) [@gent.spah](https://community.deeplearning.ai/u/gent.spah)\
**Post date:** [February 18, 2025, 7:45am UTC](https://community.deeplearning.ai/t/in-c3w2-assignment-is-the-data-possibly-broken/772150/2 "2025-02-18T07:45:13Z")

</div>

The grader includes a wider range of tests, the changes are that you are probably not implementing the solutions correctly. I would revise the solutions first.

---

<div class="post-metadata">

**Author:** ![CyberViking](https://avatars.discourse-cdn.com/v4/letter/c/aeb1de/32.png) [@CyberViking](https://community.deeplearning.ai/u/CyberViking)\
**Post date:** [February 18, 2025, 7:56am UTC](https://community.deeplearning.ai/t/in-c3w2-assignment-is-the-data-possibly-broken/772150/3 "2025-02-18T07:56:14Z")

</div>

Given that this is the input, where would all the extra text be coming from? Is it fed something other than the labels? Is train\_labels\_only and/or validation\_labels\_only have the text in them? Because that is what I am getting in my input

# Create the label encoder

train\_labels\_only = train\_dataset.map(lambda text, label: label)  
validation\_labels\_only = validation\_dataset.map(lambda text, label: label)

label\_encoder = fit\_label\_encoder(train\_labels\_only,validation\_labels\_only)

print(f’Unique labels: {label\_encoder.get\_vocabulary()}')

# GRADED FUNCTION: fit\_label\_encoder

def fit\_label\_encoder(train\_labels, validation\_labels):  
“”"Creates an instance of a StringLookup, and trains it on all labels

```
Args:
    train_labels (tf.data.Dataset): dataset of train labels
    validation_labels (tf.data.Dataset): dataset of validation labels

Returns:
    tf.keras.layers.StringLookup: adapted encoder for train and validation labels
"""
### START CODE HERE ###

```

---

<div class="post-metadata">

**Author:** ![CyberViking](https://avatars.discourse-cdn.com/v4/letter/c/aeb1de/32.png) [@CyberViking](https://community.deeplearning.ai/u/CyberViking)\
**Post date:** [February 18, 2025, 9:18am UTC](https://community.deeplearning.ai/t/in-c3w2-assignment-is-the-data-possibly-broken/772150/4 "2025-02-18T09:18:01Z")

</div>

OK I found the error, it was in Exercise 1. I passed the validation text where it should have been the validation labels. My mistake, but might be good to add to the unit tests 🙂

---

<div class="post-metadata">

**Author:** ![gent.spah](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/gent.spah/32/136423_2.png) [@gent.spah](https://community.deeplearning.ai/u/gent.spah)\
**Post date:** [February 18, 2025, 1:44pm UTC](https://community.deeplearning.ai/t/in-c3w2-assignment-is-the-data-possibly-broken/772150/5 "2025-02-18T13:44:45Z")

</div>

Great job.
