torch.utils.data.DataLoader作用:用来将数据包装为Dataset类,然后传入DataLoader中,再使用DataLoader这个类来更加快捷的对数据进行操作class DataLoader(object): r""" Data loader. Combines a dataset and a sampler, and provides single- or multi-process iterators over the dataset.
classDataLoader(object):
r"""
Data loader. Combines a dataset and a sampler,and provides
single-or multi-process iterators over the dataset.
Arguments:
dataset (Dataset): dataset from which to load the data.
batch_size (int, optional): how many samples per batch to load
(default:1).
shuffle (bool, optional):set to ``True`` to have the data reshuffled
at every epoch (default:False).
sampler (Sampler, optional): defines the strategy to draw samples from
the dataset. If specified, ``shuffle`` must be False.
batch_sampler (Sampler, optional): like sampler, but returns a batch of
indices at a time. Mutually exclusive with batch_size, shuffle,
sampler,and drop_last.
num_workers (int, optional): how many subprocesses to use for data
loading.0 means that the data will be loaded in the main process.(default:0)
collate_fn (callable, optional): merges a list of samples to form a mini-batch.
pin_memory (bool, optional): If ``True``, the data loader will copy tensors
into CUDA pinned memory before returning them.
drop_last (bool, optional):set to ``True`` to drop the last incomplete batch,if the dataset size isnot divisible by the batch size. If ``False`` and
the size of dataset isnot divisible by the batch size, then the last batch
will be smaller.(default:False)
timeout (numeric, optional):if positive, the timeout value for collecting a batch
from workers. Should always be non-negative.(default:0)
worker_init_fn (callable, optional): If notNone, this will be called on each
worker subprocess with the worker id(an intin ``[0, num_workers -1]``)asinput, after seeding and before data loading.(default:None).. note:: By default, each worker will have its PyTorch seed set to
``base_seed + worker_id``, where ``base_seed`` is a long generated
by main process using its RNG. However, seeds for other libraies
may be duplicated upon initializing workers (w.g., NumPy), causing
each worker to return identical random numbers.(See
:ref
torch.utils.data.DataLoader作用:用来将数据包装为Dataset类,然后传入DataLoader中,再使用DataLoader这个类来更加快捷的对数据进行操作class DataLoader(object): r""" Data loader. Combines a dataset and a sampler, and provides single- or multi-process iterators over the dataset.