Difference In Padding Integer And String In Keras
I'm trying to pad a text for a seq2seq model. from keras_preprocessing.sequence import pad_sequences x=[['Hello, I'm Bhaskar', 'This is Keras'], ['This is an', 'experiment']] pad_
Solution 1:
As suggested by the Error, change dtype
to object
(not string but to an object itself), It will do the job for you.
from keras.preprocessing.sequence import pad_sequences
x=[["Hello, I'm Bhaskar", "This is Keras"], ["This is an", "experiment"]]
pad_sequences(sequences=x, maxlen=5, dtype=object, padding='pre', value="<PAD>")
Output
array([['<PAD>', '<PAD>', '<PAD>', "Hello, I'm Bhaskar", 'This is Keras'],
['<PAD>', '<PAD>', '<PAD>', 'This is an', 'experiment']],
dtype=object)
Post a Comment for "Difference In Padding Integer And String In Keras"