Shortcuts

QMNIST

class torchvision.datasets.QMNIST(root: Union[str, Path], what: Optional[str] = None, compat: bool = True, train: bool = True, **kwargs: Any)[source]

QMNIST 数据集。

Parameters:
  • root (str 或 pathlib.Path) – 数据集的根目录,其 raw 子目录包含数据集的二进制文件。

  • what (string,optional) – 可以是‘train’、‘test’、‘test10k’、‘test50k’或‘nist’,分别对应于与mnist兼容的训练集、60k的qmnist测试集、与mnist测试集匹配的10k qmnist示例、剩余的50k qmnist测试示例或所有的nist数字。默认情况下,根据兼容性参数‘train’选择‘train’或‘test’。

  • compat (bool,optional) – 一个布尔值,表示每个示例的目标是类别编号(为了与MNIST数据加载器兼容)还是包含完整qmnist信息的torch向量。默认值为True。

  • 下载 (bool, 可选) – 如果为True,则从互联网下载数据集并将其放在根目录中。如果数据集已经下载,则不会再次下载。

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

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

  • train (bool,optional,compatibility) – 当未指定参数‘what’时,此布尔值决定是加载训练集还是测试集。默认值:True。

Special-members:

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

index (int) – 索引

Returns:

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

Return type:

tuple