Shortcuts

假数据

class torchvision.datasets.FakeData(size: int = 1000, image_size: Tuple[int, int, int] = (3, 224, 224), num_classes: int = 10, transform: Optional[Callable] = None, target_transform: Optional[Callable] = None, random_offset: int = 0)[source]

一个返回随机生成图像并将其作为PIL图像返回的假数据集

Parameters:
  • size (int, 可选) – 数据集的大小。默认值:1000张图片

  • image_size (tuple, 可选) – 返回图像的大小。默认值: (3, 224, 224)

  • num_classes (int, 可选) – 数据集中的类别数量。默认值:10

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

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

  • random_offset (int) – 偏移用于生成每张图像的基于索引的随机种子。默认值:0

使用 FakeData 的示例:

如何使用CutMix和MixUp

How to use CutMix and MixUp
Special-members:

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

index (int) – 索引

Returns:

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

Return type:

tuple