Python利用ctypes提高执行速度
2492
2022-08-23
ImportError: cannot import name ‘IterableDataset‘ from ‘torch.utils.data.dataset‘
今天在导入torch库的时候出现了下面的错误:
ImportError: cannot import name 'IterableDataset' from 'torch.utils.data.dataset'
我的代码是:
import jsonimport pandas as pdimport numpy as npimport torchimport torch.nn as nnimport torch.nn.functional as Ffrom torch.utils.data import Dataset, DataLoader# from torch.cuda.amp import autocast, GradScalerfrom tqdm import tqdmimport randomimport osimport timefrom sklearn.model_selection import *from transformers import *
解决方法
pip install torch==1.5
输出日志:
Looking in indexes: torch==1.5 Downloading (80.5MB) |████████████████████████████████| 80.5MB 12.0MB/sRequirement already satisfied: future in /Users/wugaosheng/anaconda3/lib/python3.7/site-packages (from torch==1.5) (0.18.2)Requirement already satisfied: numpy in /Users/wugaosheng/anaconda3/lib/python3.7/site-packages (from torch==1.5) (1.19.5)ERROR: torchnlp 0.0.0.1 has requirement torch==1.0.0, but you'll have torch 1.5.0 which is incompatible.Installing collected packages: torch Found existing installation: torch 1.0.0 Uninstalling torch-1.0.0: Successfully uninstalled torch-1.0.0Successfully installed torch-1.5.0
参考文献
FARMReader on Conda Environment
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~