大佬教程收集整理的这篇文章主要介绍了如果使用 texts_to_matrix 使用 X 训练模型,如何标记文本?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我是 TensorFlow 的新手,我想知道如何标记字符串以预测 X_Train、X_test 是否使用 texts_to_matrix 标记。该模型用于分类,从新闻(商业、政治、体育...)中区分不同的类别。
tokenize = tf.keras.preprocessing.text.Tokenizer(num_words=1000,char_level=falsE)
tokenize.fit_on_texts(X_Train_1)
X_Train = tokenize.texts_to_matrix(X_Train_1)
X_test = tokenize.texts_to_matrix(X_test_1)
model.fit ...
test_text = 'Im super insecure AND unsure of everything'
test = tokenize.texts_to_matrix(test_text)
print(test.shapE) # should be (1000,)
(43,1000)
test_pred = model.preDict(np.array([test]))
text_labels[np.argmax(test_pred)]
---------------------------------------------------------------------------
IndexError TraceBACk (most recent call last)
<ipython-input-67-51b109f3505f> in <module>()
----> 1 text_labels[np.argmax(test_pred)]
IndexError: index 78 is out of bounds for axis 0 with size 6
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
以上是大佬教程为你收集整理的如果使用 texts_to_matrix 使用 X 训练模型,如何标记文本?全部内容,希望文章能够帮你解决如果使用 texts_to_matrix 使用 X 训练模型,如何标记文本?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。