datasets.rst 1.94 KB
Newer Older
1
2
3
4
5
6
7
8
Datasets
========

Torchvision provides many built-in datasets in the ``torchvision.datasets``
module, as well as utility classes for building your own datasets.

Built-in datasets
~~~~~~~~~~~~~~~~~
Sasank Chilamkurthy's avatar
Sasank Chilamkurthy committed
9
10
11
12

All datasets are subclasses of :class:`torch.utils.data.Dataset`
i.e, they have ``__getitem__`` and ``__len__`` methods implemented.
Hence, they can all be passed to a :class:`torch.utils.data.DataLoader`
13
which can load multiple samples in parallel using ``torch.multiprocessing`` workers.
Sasank Chilamkurthy's avatar
Sasank Chilamkurthy committed
14
For example: ::
15

16
    imagenet_data = torchvision.datasets.ImageNet('path/to/imagenet_root/')
17
    data_loader = torch.utils.data.DataLoader(imagenet_data,
Sasank Chilamkurthy's avatar
Sasank Chilamkurthy committed
18
19
20
21
                                              batch_size=4,
                                              shuffle=True,
                                              num_workers=args.nThreads)

22
.. currentmodule:: torchvision.datasets
Sasank Chilamkurthy's avatar
Sasank Chilamkurthy committed
23
24
25

All the datasets have almost similar API. They all have two common arguments:
``transform`` and  ``target_transform`` to transform the input and target respectively.
26
You can also create your own datasets using the provided :ref:`base classes <base_classes_datasets>`.
27

28

29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
.. autosummary::
    :toctree: generated/
    :template: class_dataset.rst

    Caltech101
    Caltech256
    CelebA
    CIFAR10
    CIFAR100
    Cityscapes
    CocoCaptions
    CocoDetection
    EMNIST
    FakeData
    FashionMNIST
    Flickr8k
    Flickr30k
46
    FlyingChairs
47
    FlyingThings3D
48
49
50
51
52
    HMDB51
    ImageNet
    INaturalist
    Kinetics400
    Kitti
53
    KittiFlow
54
55
56
57
58
59
60
61
62
63
64
65
    KMNIST
    LFWPeople
    LFWPairs
    LSUN
    MNIST
    Omniglot
    PhotoTour
    Places365
    QMNIST
    SBDataset
    SBU
    SEMEION
66
    Sintel
67
68
69
70
71
72
73
    STL10
    SVHN
    UCF101
    USPS
    VOCSegmentation
    VOCDetection
    WIDERFace
74
75
76
77
78
79

.. _base_classes_datasets:

Base classes for custom datasets
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

80
81
82
.. autosummary::
    :toctree: generated/
    :template: class.rst
83

84
85
86
    DatasetFolder
    ImageFolder
    VisionDataset