Pytorch Tutorial
Most of the content here is from the Official Pytorch tutorial. I made this to be more concise and to present to a class. You can get the notebook here. PyTorch Background Data in PyTorch is stored in Tensors, which are almost identical to NumPy arrays. Their key differences are Auto gradient calculation (with torch.autograd) Ability to move to a GPU (with Tensor.to(device)) import torch data = [[1,2,3], [4,5,6], [7,8,9]] data_tensor = torch.tensor(data) print(data_tensor) tensor([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) ones_tensor = torch.ones(size=data_tensor.shape, dtype=int) print(ones_tensor) # these tensors behave almost exactly like numpy arrays print(ones_tensor @ data_tensor) tensor([[1, 1, 1], [1, 1, 1], [1, 1, 1]]) tensor([[12, 15, 18], [12, 15, 18], [12, 15, 18]]) Datasets & DataLoaders Some datasets are available from Pytorch’s own libraries, such as MNIST or Fashion-MNIST ...