C3W3 Graded Assignment Error

I am getting the ‘Data cardinality is ambiguous’ error while solving the ’ Define a model that does not overfit’ section of the C3W3 assignment. Please explain what am I doing wrong and how should I fix it.

Hi @Ten_sorFlow

Based on your error output your X and Y arrays are not of the same size…that is you have less number of labels than the number of samples.

  1. So thinks to check would be first parse_data_from_file would be if you correctly recalled the labels and sentences according to instructions given
  • csv.reader returns an iterable that returns each row in every iteration. So the label can be accessed via row[0] and the text via row[5].
  1. If point 1 is correct, then train_val_split need to correctly split the sentences and label into train val(make sure this is correctly split and your output matches with the expected output.

  2. Then can I know what loss and optimizer you used?

  3. Also make sure while creating your model in the embedding layer, it should vocab_size +1. Also remember the argument mentions weights is embeddings_matrix and it is an array, so make sure you are mentioning it as [embedding_matrix]

  4. You last dense unit would decide what activation you have used, based on which your loss also would be determined.

let me know if you check through all this correctly and yet are failing at the training!!!

Regards
DP

Hi @Deepti_Prasad ,
I will check all the points you have mentioned. For the loss I have used “binary crossentropy” and for optimizer I have used “adam”. I get back to you as soon as I have checked all the functions thoroughly.

Regards,
@Ten_sorFlow

1 Like

Hi @Deepti_Prasad,
I checked my assignment and found the problem! It was in the ‘parse_data_from_file’ function. I hadn’t properly defined the ‘for loop’ for the access of labels and texts.
Thank you so much for your help!
Regards,
@Ten_sorFlow

1 Like