python tokenize_model_python-AttributeError:“令牌生成器”对象在Keras中没有属性“ oov_token”...

我正在尝试使用加载的令牌生成器对文本进行编码,但出现以下错误

AttributeError: 'Tokenizer' object has no attribute 'oov_token'

我包括以下代码:

from keras.preprocessing.text import Tokenizer

from keras.preprocessing import sequence

from keras.models import Model, Input, Sequential, load_model

import pickle

import h5py

maxlen = 100

tok = open('tokenizer.pickle', 'rb')

tokenizer = pickle.load(tok)

tok.close()

model = load_model('weights.h5')

def predict():

new_text = sequence.pad_sequences((tokenizer.texts_to_sequences(['heyyyy'])), maxlen=maxlen)

prediction = model.predict(new_text,batch_size=1,verbose=2)

该问题发生在行tokenizer.texts_to_sequences([‘heyyyy’])上,我不确定为什么.泡菜有问题吗? tokenizer.texts_to_sequences与’hey’,’heyy’和’heyyy’一起使用.

任何指导表示赞赏!

你可能感兴趣的:(python,tokenize_model)