Pytorch
Pytorch Notes
ImageNet Database : A very large dataset of over 14 million images maintained by stanford university.
Downloading CIFAR-10 Dataset.
from torchvision import datasets
import os
data_path = "../data-path/p1ch7"
os.makedirs(data_path, exist_ok = True)
cifar10 = datasets.CIFAR10(data_path, train = True, download = True)
cifar10_val = datasets.CIFAR10(data_path, train = False, download = True)
Every dataset is returned as a subclass of torch.utils.data.Dataset
The Dataset class ( subclass of torch.utils.data.Dataset )
The object of the class Dataset should have 2 methods.
- len - Should return the number of items in the dataset.
- getitem - Should return the item, consisting of a sample and its corresponding label ( an integer index ).
Dataset Transormations
We need a way to convert the Python PIL Image to a pytorch tensor, before we can do anything with it.
That's were torchvision.transformers comes in.