完整的神经网络模型验证套路

       以下就是完整的神经网络模型验证套路,我们拿到的数据集是CIFAR10,CIFAR-10数据集由10个类的60000个32x32彩色图像组成,每个类有6000个图像。有50000个训练图像和10000个测试图像。它能够将图像进行10分类。我们训练好我们的模型之后,那么模型已经保存好了,我们就要拿这个模型来验证我们的分类效果如何,下面就是完整的神经网络模型验证套路:

# 姓   名:杨雅静
# 开发时间:2021/11/15 9:33
import torch
import torchvision
from PIL import Image
from torch import nn
from torch.nn import Conv2d, MaxPool2d, Flatten, Linear

image_path="F:\learn-pytorch\image\miao.png"
image = Image.open(image_path)
print(image)

transform=torchvision.transforms.Compose([torchvision.transforms.Resize((32,32)),torchvision.transforms.ToTensor()])
image=transform(image)

print(image.shape)


class net_work(nn.Module):   #这是搭建的神经网络模型,可写可不写,删掉也可以
    def __init__(self):
        super(net_work, self).__init__()
        self.model = nn.Sequential(
            Conv2d(3, 32, 5, padding=2),
            MaxPool2d(2),
            Conv2d(32, 32, 5, padding=
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值