我正在尝试了解有关 Tensorflowjs 的更多信息,但遗憾的是,我无法将我的 Keras NLP 模型转换为 Tensorflowjs。
这就是我要转换的内容:
from keras.models import load_model
from keras.preprocessing.sequence import pad_sequences
import pickle
list_classes = ["toxic", "severe_toxic", "obscene", "threat", "insult", "identity_hate"]
model = load_model('Keras_Model/m.hdf5')
with open('Keras_Model/tokenizer.pkl', 'rb') as handler:
tokenizer = pickle.load(handler)
list_sentences_train = ["I need help Stackoverflow"]
list_tokenized_train = tokenizer.texts_to_sequences(list_sentences_train)
maxlen = 200
X_t = pad_sequences(list_tokenized_train, maxlen=maxlen)
pred = model.predict(X_t)[0]
Tensorflowjs 方面:
import tf = require('@tensorflow/tfjs-node')
async function processModel(){
const model = await tf.loadLayersModel('Server_Model/model.json');
}
如何让 Tokenizer 运行并做出正确的预测?