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?
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.
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 ###
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 
1 Like