当前位置:网站首页>机器学习之卷积神经网络使用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复制到桌面
打开
打开一张图片

边栏推荐
- 如何根据多元索引查询最后一条数据,达到 sql order by desc limit 1的效果呢?
- Tiktok actual battle ~ list of bloggers I follow, follow and check
- Lecturer solicitation order | Apache dolphin scheduler meetup sharing guests, looking forward to your topic and voice!
- Qt5.5.1配置MSVC2010编绎器和windbg调试器
- No win32/com in vs2013 help document
- QT create 5.0.3 configuring qt4.8.7
- Change exchange (dynamic planning)
- 开源技术交流丨一站式全自动化运维管家ChengYing入门介绍
- Qt create 5.0.3 配置Qt4.8.7
- 数组中的第K大元素[堆排 + 建堆的实际时间复杂度]
猜你喜欢

【Spock】处理 Non-ASCII characters in an identifier

Opengauss kernel: analysis of SQL parsing process

A new 25K byte from the Department showed me what the ceiling is

Fleet |「後臺探秘」第 3 期:狀態管理

Flutter simply implements multilingual internationalization

Geoffrey Hinton:我的五十年深度学习生涯与研究心法

抖音实战~我关注的博主列表、关注、取关

5 minutes to make a bouncing ball game

Flutter简单实现多语言国际化

Practice of curve replacing CEPH in Netease cloud music
随机推荐
字节跳动数据平台技术揭秘:基于ClickHouse的复杂查询实现与优化
Naacl 2022 | distillation of machinetranslation SOTA model
【LeetCode】13、罗马数字转整数
Application of mongodb in Tencent retail premium code
Big God explains open source buff gain strategy live lecture
Jenkins的安装及使用
今天睡眠质量记录80分
Talking about open source - Linus and Jim talk about open source in China
The world has embraced Web3.0 one after another, and many countries have clearly begun to seize the initiative
leetcode:22. 括号生成
超自动化与网络安全的未来
The Web3.0 era is coming. See how Tianyi cloud storage resources invigorate the system to enable new infrastructure (Part 1)
Opengauss kernel: analysis of SQL parsing process
Opengauss kernel: analysis of SQL parsing process
Introduction to deep learning in machine learning
早晨有些犹豫
MIPS assembly language learning -02- logic judgment - foreground input
3. Caller 服务调用 - dapr
PostgreSQL enables grouping statistics by year, month, day, week, hour, minute and second
What are the most powerful small and medium-sized companies in Beijing?