Table of Contents
Shortcuts

# ImageNet

class torchvision.datasets.ImageNet(root: str, split: str = 'train', **kwargs: Any)

  ImageNet 2012 Classification Dataset.

  Note

  Before using this class, it is required to download ImageNet 2012 dataset from here and place the files `ILSVRC2012_devkit_t12.tar.gz` and `ILSVRC2012_img_train.tar` or `ILSVRC2012_img_val.tar` based on `split` in the root directory.

  Parameters:

    - root (string) – Root directory of the ImageNet Dataset.

    - split (string, optional) – The dataset split, supports `train`, or `val`.

    - transform (callable, optional) – A function/transform that takes in an PIL image and returns a transformed version. E.g, `transforms.RandomCrop`

    - target_transform (callable, optional) – A function/transform that takes in the target and transforms it.

    - loader – A function to load an image given its path.

  Special-members:

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

      index (int) – Index

    Returns:

      (sample, target) where target is class_index of the target class.

    Return type:

      tuple

## Docs

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

To analyze traffic and optimize your experience, we serve cookies on this site. By clicking or navigating, you agree to allow our usage of cookies. As the current maintainers of this site, Facebook’s Cookies Policy applies. Learn more, including about available controls: Cookies Policy.