快捷鍵

CIFAR10

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

CIFAR10 資料集。

參數:
  • root (str 或 pathlib.Path) – 資料集的根目錄,如果 download 設定為 True,則目錄 cifar-10-batches-py 存在或將儲存到此目錄。

  • train (bool, optional) – 如果為 True,則從訓練集建立資料集,否則從測試集建立資料集。

  • 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 的完整開發者文件

查看文件

教學課程

取得針對初學者和進階開發人員的深入教學課程

查看教學課程

資源

尋找開發資源並獲得您的問題解答

查看資源