100% found this document useful (1 vote)
39 views37 pages

Discussion 4 Pytorch

This document provides an overview of PyTorch concepts including tensors, datasets, data loaders, neural networks, optimization, and saving/loading models. It discusses initializing and operating on tensors, loading and iterating through datasets, defining neural network modules and classes, using loss functions and optimizers for training, and implementing train/test loops. The document also acknowledges the PyTorch official tutorial for more detailed information.

Uploaded by

张竞择
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
39 views37 pages

Discussion 4 Pytorch

This document provides an overview of PyTorch concepts including tensors, datasets, data loaders, neural networks, optimization, and saving/loading models. It discusses initializing and operating on tensors, loading and iterating through datasets, defining neural network modules and classes, using loss functions and optimizers for training, and implementing train/test loops. The document also acknowledges the PyTorch official tutorial for more detailed information.

Uploaded by

张竞择
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 37

Drew Kaul

CS 231N PyTorch Tutorial April 22


Fashion-MNIST

Xiao et al. Fashion-mnist: a novel image dataset for benchmarking machine learning algorithms.
arXiv preprint arXiv:1708.07747.
Tensors
Initializing a Tensor
Initializing a Tensor
Attributes of a Tensor
Operations on Tensors
Operations on Tensors
Operations on Tensors
Datasets & DataLoaders
Loading a Dataset
Iterating and Visualizing the Dataset
Iterating and Visualizing the Dataset
Creating a Custom Dataset for your files
Creating a Custom Dataset for your files
Creating a Custom Dataset for your files
Creating a Custom Dataset for your files
Preparing your data for training with
DataLoaders
Iterate through the DataLoader
Iterate through the DataLoader
Neural Network
torch.nn.Module
Get Device for Training
Define the Class
Define the Class
Define the Class
Optimizing Model Params
Loss Function
Optimizer
Full Implementation – Train Loop
Full Implementation – Test Loop
Full Implementation
Full Implementation
Save and Load the Model
Saving and Loading Model Weights
Saving and Loading Models with Shapes
Acknowledgment

• PyTorch Official Tutorial:


https://pytorch.org/tutorials/beginner/basics/intro.html

• Feel free to check out the tutorial for more details!

You might also like