把薄书读厚,典型案例详解
pytorch-CNN经典案例拆解
案例出自:
https://github.com/yunjey/pytorch-tutorial.git
关注用案例学Pytorch:
https://github.com/houhuipeng/EasyPytorch-ByExample.git
本案例与CNN卷积网络类似,注释较少。
案例带你学Pytorch系列(3)——GNN生成对抗网络,即将推出,欢迎关注
import torch
import torch.nn as nn
import torchvision
import torchvision.transforms as transforms
device = torch.device('cuda' if torch.cuda.is_available () else 'cpu')
sequence_length = 28
input_size = 28
hidden_size = 128
num_layers = 2
num_classes = 10
batch_size = 100
num_epochs = 1
learning_rate = 0.01
train_dataset = torchvision.datasets.MNIST(root = '../../data/',
train= True,