NLP C3W3 Assignment - error grading submission?

Hello, I am getting grading errors :

on train_val_datasets - name ‘sentences’ not defined - even though ‘sentences’ is defined in the field above

on fit_vectorizer - name ‘df’ not defined - even though ‘df’ is defined in the field above

even though for ‘create_model’ and ‘history’ exercises I got the full score.
Would anyone have an idea what am I doing wrong ?

check if you have not mixed local variables with global variables

1 Like

Hello ,thanks for a reply

I indeed found one excess definition of ‘sentences’ in the code.

However, after fixing I get the sentences not defined grader error for both exexrcise 1 and 2, which is strange as now sentences is defined only once as a global variable.

Post screenshot of the errors

based on exercise 1 and 2 codes, there were no place where sentences was required

You probably used the below code from non-graded cell in the train_val dataset


Create the dataset
dataset = tf.data.Dataset.from_tensor_slices((sentences, labels))


where as you were suppose to use :point_down:t2:


Args:
        dataset (tf.data.Dataset): Tensorflow dataset with elements as (sentence, label)
    

make sure you are only writing codes as per the instructions already given in the grade cell and do not hard code any of path.

  1. For this step​:point_down:t2:

Split the sentences and labels into train/validation splits

You are suppose to use hint :point_down:t2:

Take a look at the take and skip methods to generate the training and validation data.

  1. For this step
    Turn the dataset into a batched dataset with BATCH_SIZE elements each.Use the batch method
    tf.data.Dataset  |  TensorFlow v2.16.1

Regards
DP

The code “dataset = tf.data.Dataset.from_tensor_slices((sentences, labels))” was actually already in one of the frozen fields I can not edit :

yes that’s why I mentioned non grade cell, but did you use the same step in train_val?

Hello

Thanks for bearing with me.
I did use the hinted take and skip methods to define train_dataset and validation_dataset, and there is no other definition of ‘sentences’ anywhere else .

please send screenshot of your codes for which your grader failed by personal DM

You added extra codes in fit vectorizer grade cell, there was only instantiation of textvectorizer class and fitting the vectorizer to the training sentences, so I don’t know from where you added again the train split codes here. Get fresh copy and redo your assignment, and always remember stick to writing codes only as per the instructions already given and not adding/deleting or editing anything which was anything outside the ###Start and end code here###