Machine learning 关于使用文本列表加载数据的FastAI问题
我的最终目标是使用FastAI实现ULMFit以预测灾难推文(作为Kaggle竞赛的一部分)。我想做的是从数据帧中读取推文。但由于我不知道的原因,我被困在数据加载阶段。我无法用下面的方法来做-Machine learning 关于使用文本列表加载数据的FastAI问题,machine-learning,deep-learning,fast-ai,Machine Learning,Deep Learning,Fast Ai,我的最终目标是使用FastAI实现ULMFit以预测灾难推文(作为Kaggle竞赛的一部分)。我想做的是从数据帧中读取推文。但由于我不知道的原因,我被困在数据加载阶段。我无法用下面的方法来做- from fastai.text.all import * train= pd.read_csv('../input/nlp-getting-started/train.csv') dls_lm = (TextList.from_df(path,train,cols='text',is_lm=True)
from fastai.text.all import *
train= pd.read_csv('../input/nlp-getting-started/train.csv')
dls_lm = (TextList.from_df(path,train,cols='text',is_lm=True)
.split_by_rand_pct(0.1)
#.label_for_lm()
.databunch(bs=64))
此行抛出-name错误:未定义名称“TextList”
我可以用下面的代码解决这个问题-
dls_lm = DataBlock(
blocks=TextBlock.from_df('text', is_lm=True),
get_x=ColReader('text'),
splitter=RandomSplitter(0.1)
# using only 10% of entire comments data for validation inorder to learn more
)
dls_lm = dls_lm.dataloaders(train, bs=64, seq_len=72)
为什么这个方法有效而不是以前的方法
供参考。您正在运行哪个版本的fastai
import fastai
print(fastai.__version__)
TextList类来自FastAI v1,但在我看来,您的导入路径是针对FastAI v2的,在v2中,TextList被更改为(这就是为什么它使用数据块部分,这是处理此问题的好方法)我使用的是版本2.2.5。谢谢你的建议。