設置Torch國內鏡像網絡
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
安裝PyTorch和TorchVision測試
conda install pytorch torchvision
測試pytorch版本spa
import torch import torchvision print(torch.__version__) print(torchvision.__version__) encoder = torchvision.models.resnet34(pretrained=True) print(type(encoder.conv1.weight)) print(encoder.conv1.weight.shape)
其中這句,encoder = torchvision.models.resnet34(pretrained=True),會自動下載預訓練好的resnet34網絡,可是速度較慢,且容易斷,還沒斷點續傳功能。用迅雷下載https://download.pytorch.org/models/resnet34-333f7ec4.pth 到 ~/.torch/models/resnet34-333f7ec4.pth具體下載地址,和存放路徑,根據運行提示而定便可。