阅读背景:

如何自定义数据集

来源:互联网 

pytorch读取图片,主要是通过Dataset类。

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])c



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: