快捷方式

SVHN

class torchvision.datasets.SVHN(root: Union[str, Path], split: str = 'train', transform: Optional[Callable] = None, target_transform: Optional[Callable] = None, download: bool = False)[source]

SVHN 数据集。注意:SVHN 数据集将标签 10 分配给数字 0。然而,在此数据集中,我们将标签 0 分配给数字 0,以与 PyTorch 损失函数兼容,后者期望类别标签在 [0, C-1] 范围内。

警告

此类别需要 scipy 来加载 .mat 格式的数据。

参数:
  • root (str 或 pathlib.Path) – 数据集的根目录,数据存储在此处。

  • split (string) – {‘train’, ‘test’, ‘extra’} 之一。据此选择数据集。‘extra’ 是额外训练集。

  • transform (callable, optional) – 一个函数/变换,接收 PIL 图像并返回变换后的版本。例如,transforms.RandomCrop

  • target_transform (callable, optional) – 一个函数/变换,接收目标并对其进行变换。

  • download (bool, optional) – 如果为 True,则从互联网下载数据集并将其放入根目录。如果数据集已下载,则不再重复下载。

特殊成员:

__getitem__(index: int) Tuple[Any, Any][source]
参数:

index (int) – 索引

返回:

(image, target),其中 target 是目标类别的索引。

返回类型:

tuple

文档

访问 PyTorch 的全面开发者文档

查看文档

教程

获取适合初学者和高级开发者的深度教程

查看教程

资源

查找开发资源并获得问题解答

查看资源