pytorch 小土堆学习笔记
文章目录
P6 P7 加载数据与实战
1. Dataset
Dataset:提供一种方式去获取数据及其label
实现功能:
1.如何获取每一个数据及其label
2.告诉我们总共有多少个数据
2. Dataloader
Dataloader:为后面的网络提供不同的数据形式
对Dataset数据进行打包/压缩(batchsize)后,将数据送进网络
# use of class Dataset
from torch.utils.data import Dataset
help(Dataset)
help(Dataset) 能看到Dataset的用法解释:
Help on class Dataset in module torch.utils.data.dataset:
class Dataset(typing.Generic)
| Dataset(*args, **kwds)
|
| An abstract class representing a :class:`Dataset`.
|
| All datasets that represent a map from keys to data samples should subclass
| it. All subclasses should overwrite :meth:`__getitem__`, supporting fetching a
| data sample for a given key. Subclasses could also optionally overwrite
| :meth:`__len__`, which is expected to return the `在这里插入代码片`size of the dataset by many
| :class:`~torch.utils.data.Sampler` implementations and the default options
| of :class:`~torch.utils.data.DataLoader`.
|
| .. note::
| :class:`~torch.utils.data.DataLoader` by default constructs a index
| sampler that yields integral indices. To make it work with a map-style
| dataset with non-integral indices/keys, a custom sampler must be provided.
|
| Method resolution order:
| Dataset
| typing.Generic
| builtins.object
|
| Methods defined here:
|
| __add__(self, other: 'Dataset[T_co]') -> 'ConcatDataset[T_co]'
|
| __getattr__(self, attribute_name)
|
| __getitem__(self, index) -> +T_co
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| register_datapipe_as_function(function_name, cls_to_register, enable_df_api_tracing=False) from builtins.type
|
| register_function(function_name, function) from builtins.type
|
| --------------------------------------------------------------------