快捷方式

USPS

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 資料集。資料格式為:[label [index:value ]*256 n] * num_lines,其中 label[1, 10] 中。每個畫素的值在 [-1, 1] 中。在此我們將 label 轉換為 [0, 9],並將畫素值轉換為 [0, 255]

引數:
  • root (str 或 pathlib.Path) – 資料集根目錄,用於儲存``USPS`` 資料檔案。

  • train (bool, optional) – 若為 True,則從 usps.bz2 建立資料集;否則從 usps.t.bz2 建立。

  • transform (callable, optional) – 一個函式/轉換,接收 PIL 影像並返回轉換後的版本。例如,transforms.RandomCrop

  • target_transform (callable, optional) – 一個函式/轉換,接收目標並對其進行轉換。

  • download (bool, optional) – 若為 true,則從網際網路下載資料集並將其放入 root 目錄。如果資料集已下載,則不再下載。

特殊成員:

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

index (int) – 索引

返回:

(image, target),其中 target 是目標類別的索引。

返回型別:

tuple

文件

訪問 PyTorch 的全面開發者文件

檢視文件

教程

獲取針對初學者和高階開發者的深入教程

檢視教程

資源

查詢開發資源並獲得問題解答

檢視資源