python - texts_to_sequences() 缺少 1 个必需的位置参数:“文本”
问题描述
我有一系列形状为 ((8084,)) (UTF-8) 的注释,当我运行此 cod 时出现错误
from keras.preprocessing.text import Tokenizer
X = Tokenizer.texts_to_sequences(data['comment_text'].values)
错误是 TypeError: texts_to_sequences() missing 1 required positional argument: 'texts'
解决方案
texts_to_sequence
不是类方法,这不是调用它的方式。查看文档以获取示例。
您应该首先创建一个 Tokenizer 对象并对其进行拟合,然后您可以调用texts_to_sequence
.
from keras.preprocessing.text import Tokenizer
texts = data['comment_text'].values
tokenizer = Tokenizer()
tokenizer.fit_on_texts(texts)
X = tokenizer.texts_to_sequences(texts)
推荐阅读
- reactjs - Material-UI、Reactjs 中的表单
- javascript - 反应:将 HTML 元素的值传递给事件处理程序 onClick
- java - 如何在Android Java中连续制作2个按钮并在一列中制作2个按钮?
- python-3.x - 我的作业文档中的 NLP 示例崩溃了
- swift - 来自数组的 RxSwift 可观察对象序列
- azure - 使用 Azure IoT 设备预配服务在属性更改和事件订阅时触发事件
- python - soup.find(class_="") 不适用于加密站点
- r - R:当序列长度不等时计算马尔可夫转移矩阵
- python - 当我给它图像时,我的 keras 模型给了我随机预测
- r - ggplot2使用位置dodge2时具有分类和数值的堆叠条