Pytorch 搭建神经网络(5)完整模型训练
Pytorch (CIFAR10)
官方文档 中文 https://www.pytorchtutorial.com/docs/
官方文档 https://pytorch.org/docs/stable/index.html
1. Structure

2 Code
train_model.py
1 | import torch |
train.py
1 | """ CIFAR Dataset """ |
output
1 | ----------第 1 轮训练开始---------- |
3 Visualization & Save
1 | """ CIFAR Dataset """ |




4 Full Code
1 | """ CIFAR Classification """ |
5 GPU
1. Google Colab
- Google Colab: https://colab.research.google.com/

- 配置

- cpu 大约42s gpu 大约8s

2. Method 1: .cuda()
1 | ''' GPU ''' |
3. Method 2: .to(device)
1 | device = torch.device("cuda" if torch.cuda.is_available() else "cpu") |
6 Validation and Test
1 | import torchvision.transforms |


本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来源 isKage`Blog!



