Reputation: 3
python code
the problem is when uploading a txt file and try to run the code as shown in the picture I'll get the error
TypeError: texts_to_matrix() got an unexpected keyword argument 'num_words'
Upvotes: 0
Views: 337
Reputation: 538
An alternative solution if you are reading the model from your directory then follow the steps:
import pickle
with open('./outputs/tokenizer'+model_name+'.pickle', 'rb') as handle:
tokenizer = pickle.load(handle)
tokenizer.num_words = 10000
If you face the dimensions mismatch then you can verify what is the pre-define num_words. Just run -
print(tokenizer.num_words)
Upvotes: 0
Reputation: 136
You passing "num_words" argument at wrong place. Check below code snippet.
from tf.keras.preprocessing.text import Tokenizer
tokenizer = Tokenizer(num_words=10)
tokenizer.texts_to_matrix(texts, mode="binary")
Checkout this official documentation https://www.tensorflow.org/api_docs/python/tf/keras/preprocessing/text/Tokenizer
Upvotes: 1