Shortcuts

美国邮政服务

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

USPS 数据集。 数据格式为:[标签 [索引:值]*256 n] * 行数,其中 标签 位于 [1, 10]。 每个像素的值位于 [-1, 1]。这里我们将 标签 转换为 [0, 9] 并将像素值转换为 [0, 255]

Parameters:
  • root (str 或 pathlib.Path) – 数据集的根目录,用于存储``USPS``数据文件。

  • train (bool, 可选) – 如果为True,则从usps.bz2创建数据集, 否则从usps.t.bz2创建。

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

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

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

Special-members:

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

index (int) – 索引

Returns:

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

Return type:

tuple