CNN实现手写数字识别

CNN实现手写数字识别_第1张图片

 

import torch
from torchvision import transforms
from torchvision import datasets
from torch.utils.data import DataLoader
import torch.optim as optim
import torch.nn.functional as F
import matplotlib.pyplot as plt

batch_size = 64

transform = transforms.Compose([
    transforms.ToTensor(),
    transforms.Normalize((0.1307),(0.3081)) #两个参数,平均值和标准差

])

train_dataset = datasets.MNIST(
    root="../dataset/mnist/",
    train= True,
    download= True,
    transform= transform
)

train_loader = DataLoader(train_dataset,
                          shuffle = True,
             

你可能感兴趣的:(cnn,cnn,深度学习,python)