使用paddle实现手写数字识别
import paddle
from paddle.nn import Linear
import paddle.nn.functional as F
import os
import numpy as np
import matplotlib.pyplot as plt
from PIL import Image
class MNIST(paddle.nn.Layer):
def __init__(self):
super(MNIST, self).__init__()
self.fc = paddle.nn.Linear(in_features=784, out_features=1)
def forward(self, inputs):
outputs = self.fc(inputs)
return outputs
model = MNIST()
def train(model):
model.train()
train_loader = paddle.io.DataLoader(paddle.vision.datasets.MNIST(mode='train'),
batch_size=16,
shuffle=True)
opt = paddle.optimizer.SGD(learning_rate=