我在G驱动器中存储了一个csv文件,并尝试将其加载到torchtext data.TablerDataset。错误消息是“FileNotFoundError:[Errno 2]没有这样的文件或目录:”https://.....“
是否无法将csv文件从g驱动器直接加载到torchtext TablerDataset
这是代码。我还公开了一份{a1}报告,其中提供了公开的数据
import torch
from torchtext import data, datasets
!pip install -U -q PyDrive
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
from google.colab import auth
from oauth2client.client import GoogleCredentials
auth.authenticate_user()
gauth = GoogleAuth()
gauth.credentials = GoogleCredentials.get_application_default()
drive = GoogleDrive(gauth)
TEXT = data.Field(tokenize = 'spacy', batch_first = True, lower=False)
LABEL = data.LabelField(sequential=False, dtype = torch.float)
train = data.TabularDataset(path = 'https://drive.google.com/open?id=1eWMjusU3H34m0uml5SdJvYX6gQuB8zta',
format = 'csv',
fields = [('Insult', LABEL), (None, None), ('Comment', TEXT)],
skip_header=False)
假设您有能力下载此CSV文件。我建议您在torchtext上使用功能内置的:
download_from_url
请注意,googledrive链接不应该是带有
open?id
的链接,而是将其更改为uc?export=download&id
相关问题 更多 >
编程相关推荐