1.什麼是Pytorch,爲什麼選擇Pytroch?
- 作爲NumPy的替代品,可以利用GPU的性能進行計算
- 作爲一個高靈活性、速度快的深度學習平臺
- Pytorch相比Tensorflow而言,它的設計初衷是簡單易用用,所以它是基於動態圖進行實現的,從而方便調試。當然,Tensorflow在1.5版的時候就引入了Eager Execution機制實現了動態圖,但它還是默認使用靜態圖。
2.Pytroch的安裝
- 配置Python環境:
- 安裝anaconda,
- 打開Anaconda prompt,輸入conda install pytorch-cpu -c pytorch,下載packages,
- 再輸入pip install torchvision,torchvision安裝成功。驗證是否下載成功:打開Anaconda jupyter notebook,輸入print(import torch),print(import torchvision),print(torch)
不報錯即可。
3.PyTorch基礎概念
參考
https://blog.csdn.net/herosunly/article/details/88892326
https://blog.csdn.net/herosunly/article/details/88915673
4.Pytorch基本實現
# 4.PyTorch
mport torch as t
import torchvision as tv
import torchvision.transforms as transforms
from torch.autograd import Variable
import torch.nn as nn
import torch.nn.functional as F