Pytorch 笔记
不定时更新
Pytorch 常用包
# torch.tensor(), torch.device(), torch.max()
import torch
# nn.Module, nn.Conv2d, nn.ReLU(), nn.Linear()
import torch.nn as nn
# F.avg_pool2d(), F.max_pool2d(), F.relu()
import torch.nn.functional as F
# optim.SGD()
import torch.optim as optim
# lr_scheduler.StepLR()
import torch.optim.lr_scheduler as lr_scheduler
# DalaLoader
from torch.utils.data import DataLoader, Dataset
# transforms.Compose(), datasets.CIFAR10(), models.vgg16()
from torchvision import transforms, datasets, models
与显卡有关的参数
>>> torch.cuda.is_available()
True
>>> torch.cuda.current_device()
0
>>> torch.cuda.device_count()
1
>>> torch.version.cuda
10.0
>>> torch.backends.cudnn.version()
7401
>>> torch.cuda.get_device_name(0)
'GeForce GTX 1060'
>>> torch.cuda.get_device_capability(0)
(6, 1)