捷徑

USPS

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

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,則從網路下載資料集並將其放入根目錄。 如果資料集已下載,則不會再次下載。

特殊成員:

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

index (int) – 索引

返回值:

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

返回類型:

tuple (元組)

文件

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources