本文实例讲述了Pytorch实现的手写数字mnist识别功能。分享给大家供大家参考,具体如下:
import torch
import torchvision as tv
import torchvision.transforms as transforms
import torch.nn as nn
import torch.optim as optim
import argparse
# 定义是否使用GPU
device = torch.device(cuda if torch.cuda.is_available() else cpu)
# 定义网络结构
class LeNet(
1