当前位置:网站首页>机器学习之卷积神经网络使用cifar10数据集和alexnet网络模型训练分类模型,安装labelimg,以及报错ERROR
机器学习之卷积神经网络使用cifar10数据集和alexnet网络模型训练分类模型,安装labelimg,以及报错ERROR
2022-06-28 15:49:00 【华为云】
使用cifar10数据集和alexnet网络模型训练分类模型
下载cifar10数据集
代码:
import torchvisionimport torchtransform = torchvision.transforms.Compose( [torchvision.transforms.ToTensor(), torchvision.transforms.Resize(224)])train_set = torchvision.datasets.CIFAR10(root='./',download=False,train=True,transform=transform)test_set = torchvision.datasets.CIFAR10(root='./',download=False,train=False,transform=transform)train_loader = torch.utils.data.DataLoader(train_set,batch_size=8,shuffle=True)test_loader = torch.utils.data.DataLoader(test_set,batch_size=8,shuffle=True)class Alexnet(torch.nn.Module): #1080 2080 def __init__(self,num_classes=10): super(Alexnet,self).__init__() net = torchvision.models.alexnet(pretrained=False) #迁移学习 net.classifier = torch.nn.Sequential() self.features = net self.classifier = torch.nn.Sequential( torch.nn.Dropout(0.3), torch.nn.Linear(256 * 6 * 6, 4096), torch.nn.ReLU(inplace=True), torch.nn.Dropout(0.3), torch.nn.Linear(4096, 4096), torch.nn.ReLU(inplace=True), torch.nn.Linear(4096, num_classes), ) def forward(self,x): x = self.features(x) x = x.view(x.size(0),-1) x = self.classifier(x) return xdevice = torch.device('cpu')net = Alexnet().to(device)loss_func = torch.nn.CrossEntropyLoss().to(device)optim = torch.optim.Adam(net.parameters(),lr=0.001)net.train()for epoch in range(10): for step,(x,y) in enumerate(train_loader): # 28*28*1 32*32*3 x,y = x.to(device),y.to(device) output = net(x) loss = loss_func(output,y) optim.zero_grad() loss.backward() optim.step() print("epoch:",epoch,'loss:',loss)
安装labelimg,以及报错
目标检测标注工具:labelimg
安装 pip install labelimg
使用 labelimg
报错
ERROR: spyder 4.1.4 requires pyqtwebengine<5.13; python_version >= “3”, which is not installed. ERROR: spyder 4.1.4 has requirement pyqt5<5.13; python_version >= “3”, but you’ll have pyqt5 5.15.6 which is incompatible
版本不匹配问题
打开Anaconda Prompt
使用命令安装Spyder
pip install spyder==4.1.4
或者
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple/ spyder==4.1.4
使用 labelimg
在安装环境下找到labelimg.exe复制到桌面
打开
打开一张图片
边栏推荐
- 隐私计算 FATE - 离线预测
- Ros21 lecture
- Classic model transformer
- Realization of a springboard machine
- Flutter dart语言特点总结
- Visual Studio 2019软件安装包和安装教程
- NFT pledge LP liquidity mining system development details
- FFmpeg之禁止输出banner log(三十)
- 10年测试经验,在35岁的生理年龄面前,一文不值
- ROS knowledge points - build an ROS development environment using vscode
猜你喜欢
What! One command to get the surveillance?
Jenkins的安装及使用
Visual Studio 2010 configuring and using qt5.6.3
【推荐系统】多任务学习之ESMM模型(更新ing)
leetcode:22. 括号生成
Web3.0时代来了,看天翼云存储资源盘活系统如何赋能新基建(上)
扩充C盘(将D盘的内存分给C盘)
Slim GAIN(SGAIN)介绍及代码实现——基于生成对抗网络的缺失数据填补
What useful supplier management systems are available
Technical secrets of ByteDance data platform: implementation and optimization of complex query based on Clickhouse
随机推荐
Technical secrets of ByteDance data platform: implementation and optimization of complex query based on Clickhouse
Visual Studio 2010 配置和使用Qt5.6.3
全球陆续拥抱Web3.0,多国已明确开始抢占先机
wallys/DR7915-wifi6-MT7915-MT7975-2T2R-support-OpenWRT-802.11AX-supporting-MiniPCIe-Module
Application of mongodb in Tencent retail premium code
REDIS00_详解redis.conf配置文件
知道这几个命令让你掌握Shell自带工具
Focus on the 35 year old Kan: fear is because you don't have the ability to match your age
VS2013 帮助文档中没有 win32/com
如何查询数据库中一个表中的所有数据呢?
openGauss内核:SQL解析过程分析
In depth learning foundation summary
国债与定期存款哪个更安全 两者之间有何区别
ROS knowledge points - definition and use of topic messages
Ros21 lecture
成功迁移到云端需要采取的步骤
一种跳板机的实现思路
10年测试经验,在35岁的生理年龄面前,一文不值
Among US private server setup
Basic grammar of C language