Avisek Gupta

Indian Statistical Institute, Kolkata







Tutorial 3: Training Neural Networks







1. torch.optim updates the parameters based on the computed gradients.







2. Steps of using an optimizer:

(a) Initialize Optimizer

(b) In the Optimization loop:

i. Explicitly set the gradients to zero

ii. Compute the gradients

iii. Update the parameters using the computed gradients







3. (i) Implementing a simple one-hidden layer Multi-Layered Perceptron







3. (ii) Using torch.nn to define a network, and use a predefined loss







3. (iii) Using layers defined in torch.nn







4. Using layers defined in torch.nn, and activation functions in torch.nn.functional







5. Using data sets present in torchvision







6. To fine-tune a pre-trained CNN, it’s enough to switch the "requires_grad" flags







Recap:

1. torch.optim updates the parameters based on the computed gradients.

2. Steps of using an optimizer:

(a) Initialize Optimizer

(b) In the Optimization loop:

i. Explicitly set the gradients to zero

ii. Compute the gradients

iii. Update the parameters using the computed gradients

3. (i) Implementing a simple one-hidden layer Multi-Layered Perceptron

(ii) Using torch.nn to define a network, and use a predefined loss

(iii) Using layers defined in torch.nn

4. Using layers defined in torch.nn, and activation functions in torch.nn.functional

5. Using data sets present in torchvision

6. To fine-tune a pre-trained CNN, it’s enough to switch the "requires_grad" flags




References at the PyTorch Documentation: