I am working on the final assignment for C3W3 and all of my functions work as expected and return the correct test values except when running the seq_pad_and_truncate
function I get an TypeError deep in one of the Keras dependency functions for pad_sequences
TypeError Traceback (most recent call last)
<ipython-input-13-31226c891137> in <module>
2
3 # Test your function
----> 4 train_pad_trunc_seq = seq_pad_and_trunc(train_sentences, tokenizer, PADDING, TRUNCATING, MAXLEN)
5 val_pad_trunc_seq = seq_pad_and_trunc(val_sentences, tokenizer, PADDING, TRUNCATING, MAXLEN)
6
<ipython-input-12-523a330bbbe3> in seq_pad_and_trunc(sentences, tokenizer, padding, truncating, maxlen)
19
20 # Convert sentences to sequences
---> 21 sequences = tokenizer.texts_to_sequences(sentences)
22 # Pad the sequences using the correct padding, truncating and maxlen
23 pad_trunc_sequences = pad_sequences(sequences, padding=padding, maxlen=maxlen, truncating=truncating)
/opt/conda/lib/python3.8/site-packages/keras_preprocessing/text.py in texts_to_sequences(self, texts)
279 A list of sequences.
280 """
--> 281 return list(self.texts_to_sequences_generator(texts))
282
283 def texts_to_sequences_generator(self, texts):
/opt/conda/lib/python3.8/site-packages/keras_preprocessing/text.py in texts_to_sequences_generator(self, texts)
315 i = self.word_index.get(w)
316 if i is not None:
--> 317 if num_words and i >= num_words:
318 if oov_token_index is not None:
319 vect.append(oov_token_index)
TypeError: '>=' not supported between instances of 'int' and 'tuple'