AttributeError:模块“torchtext.dataset”没有属性“text\u classification”

2024-05-29 04:56:29 发布

您现在位置:Python中文网/ 问答频道 /正文

agnews_train, agnews_test = torchtext.datasets.text_classification.DATASETS["AG_NEWS"](root="./datasets")

在运行到上述行之后,我得到了属性错误

AttributeError Traceback (most recent call last) in ----> 1 agnews_train, agnews_test = torchtext.datasets.text_classification.DATASETS"AG_NEWS"

AttributeError:模块“torchtext.dataset”没有属性“text\u classification”


Tags: texttest属性错误trainrootdatasetsnews
1条回答
网友
1楼 · 发布于 2024-05-29 04:56:29

您可能只是使用了不同的版本。你想要的是:

agnews_train, agnews_test = torchtext.datasets.AG_NEWS(root='./datasets', split=('train', 'test'))

Documentation

相关问题 更多 >

    热门问题