当前位置:网站首页>Convolutional neural network for machine learning uses cifar10 data set and alexnet network model to train classification model, install labelimg, and report error
Convolutional neural network for machine learning uses cifar10 data set and alexnet network model to train classification model, install labelimg, and report error
2022-06-28 16:13:00 【Hua Weiyun】
Use cifar10 Data set and alexnet Network model training classification model
download cifar10 Data sets

Code :
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) # The migration study 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)install labelimg, And reporting errors
Target detection and labeling tool :labelimg
install pip install labelimg
Use labelimg

Report errors
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
Version mismatch problem
open Anaconda Prompt
Install with command Spyder
pip install spyder==4.1.4
perhaps
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple/ spyder==4.1.4

Use labelimg
Found in the installation environment labelimg.exe Copy to desktop 
open 
Open a picture

边栏推荐
- Open source technology exchange - Introduction to Chengying, a one-stop fully automated operation and maintenance manager
- Big God explains open source buff gain strategy live lecture
- The world has embraced Web3.0 one after another, and many countries have clearly begun to seize the initiative
- 5分钟的时间制作一个反弹球游戏
- Visual Studio 2010 configuring and using qt5.6.3
- 成功迁移到云端需要采取的步骤
- In depth learning foundation summary
- Tiktok actual battle ~ list of bloggers I follow, follow and check
- The k-th element in the array [heap row + actual time complexity of heap building]
- [leetcode] 13. Roman numeral to integer
猜你喜欢

5 minutes to make a bouncing ball game

Slim GAIN(SGAIN)介绍及代码实现——基于生成对抗网络的缺失数据填补

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

Why MySQL table connection is faster than subquery

【LeetCode】13、罗马数字转整数

See how the interface control devaxpress WinForms creates a virtual keyboard

部门新来了个字节25K出来的,让我见识到了什么是天花板

OpenHarmony—内核对象事件之源码详解

10 years of testing experience, worthless in the face of the physiological age of 35

Web3.0时代来了,看天翼云存储资源盘活系统如何赋能新基建(上)
随机推荐
A bug liver a week I can't help mentioning issue
Geoffrey Hinton: my 50 years of in-depth study and Research on mental skills
Introduction to reverse commissioning PE structure details 02/07
Big God explains open source buff gain strategy live lecture
The world has embraced Web3.0 one after another, and many countries have clearly begun to seize the initiative
Openharmony - detailed source code of Kernel Object Events
Among US private server setup
What is the maximum number of concurrent TCP connections for a server? 65535?
Operating excel with openpyxl
3. Caller 服务调用 - dapr
REDIS00_ Explain redis Conf configuration file
Geoffrey Hinton:我的五十年深度学习生涯与研究心法
抖音实战~我关注的博主列表、关注、取关
Android, eclipse and MySQL upload pictures and get
5分钟的时间制作一个反弹球游戏
Navicat 15 for MySQL
Technical secrets of ByteDance data platform: implementation and optimization of complex query based on Clickhouse
MySQL auto - Connect Query recommended favorites
元宇宙中能接吻了!CMU推出VR头显外挂,复刻唇部逼真触觉
The k-th element in the array [heap row + actual time complexity of heap building]