Linear Regression with Pytorch
1 PyTorch Fashion
- Prepare dataset
- Design model using Class: inherit from nn.Module
- Construct loss and optimizer: using PyTorch API
- Training cycle (forward, backward, update)
2 Prepare Dataset

3 Design Model
确认权重和张量的shape,如图中z的shape为[3,1],x的shape为[4,1],则w的shape为[3,4],b的shape为[3,1]。
4 Training Cycle
1 | import torch |
5 Exercize
5.1 Try different optimizer
- Adagrad
- Adam
- Adamax
- RMSprop
- ASGD
- LBFGS
- Rprop
- SGD