运行时出现“ModuleNotFoundError: No module named 'torch.utils.data.dataset'
怎么解决
这个错误是因为你的环境中缺少PyTorch,导致找不到torch.utils.data.dataset模块。
可以这样解决:
class torch.utils.data.Dataset
class Dataset(object):
"""An abstract class representing a Dataset.
All other datasets should subclass it. All subclasses should override
``__len__``, that provides the size of the dataset, and ``__getitem__``,
supporting integer indexing in range from 0 to len(self) exclusive.
"""
def __getitem__(self, index):
raise NotImplementedError
def __len__(self):
raise NotImplementedError
def __add__(self, other):
return ConcatDataset([self, other])
__len__
和__getitem__
。