class torchvision.datasets.FER2013(root: Union[str, Path], split: str = 'train', transform: Optional[Callable] = None, target_transform: Optional[Callable] = None)[source]

FER2013 Dataset.


This dataset can return test labels only if fer2013.csv OR icml_face_data.csv are present in root/fer2013/. If only train.csv and test.csv are present, the test labels are set to None.

  • root (str or pathlib.Path) – Root directory of dataset where directory root/fer2013 exists. This directory may contain either fer2013.csv, icml_face_data.csv, or both train.csv and test.csv. Precendence is given in that order, i.e. if fer2013.csv is present then the rest of the files will be ignored. All these (combinations of) files contain the same data and are supported for convenience, but only fer2013.csv and icml_face_data.csv are able to return non-None test labels.

  • split (string, optional) – The dataset split, supports "train" (default), or "test".

  • transform (callable, optional) – A function/transform that takes in a 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.


__getitem__(idx: int) Tuple[Any, Any][source]

index (int) – Index


Sample and meta data, optionally transformed by the respective transforms.

Return type:



Access comprehensive developer documentation for PyTorch

View Docs


Get in-depth tutorials for beginners and advanced developers

View Tutorials


Find development resources and get your questions answered

View Resources