When creating a post, please add:
- Week # must be added in the tags option of the post.
- Link to the classroom item you are referring to:
- Description (include relevant info, but please do not post solution code or your entire notebook):
I created the features and labels following the lectures, and I created one-hot encoding using tf.keras.utils.to_categorical, and finally built the dataset using tf.data. Dataset.from_tensor_slices, but I get the following error:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all(). What am I doing wrong?
please post screenshot of your error without posting any grade cell codes
Here is a screenshot of the error message.
Thank you
did you define the features and labels w.r.t. input_sequences? correctly
but your issue more seem to be coming from Grade function n_gram_sequences or grade function pad sequences
please make sure in n_gram_sequences grade function, you have converted the sentence into list of sentences using vectorizer under the for statement for line in corpus.
For pad sequence, your max len decides the sequence length and padding decide String, “pre” or “post” (optional, defaults to “pre”): pad either before or after each sequence. So as per instructions given for this exerciset was pad before each sequence.
All the unit tests before this point passed. Can I show you my code for this function?
passing unittest doesn’t always confirm your codes are correct.
Kindly click on my name and then message. please only send screenshot of the grade cell codes from first grade cell till the grade cell you failed.
hi @Mohamud_M_Mohamud
for code line
Build the dataset with the features and one hot encoded labels
You are Missing a tuple here for features and one hot labels.
Thank you for your help. That solved it