当前位置:网站首页>1.5 nn. Module neural network (III)
1.5 nn. Module neural network (III)
2022-07-29 03:22:00 【smiling0927】
1. Optimizer
1.1 After the gradient of all parameters is calculated by back propagation , We also need to use optimization methods to update the weights and parameters of the network . for example , Random gradient descent method (SGD) The update strategy is as follows :
weight= weight-learning_rate*gradientManual implementation is as follows :
learning_rate=0.01
for f in net.parameters():
f.data.sub_(f.grad_data*learning_rate)#inplace Subtraction 1.2. torch.optim It realizes most optimization methods in deep learning , for example :RMSProp、Adam、SGD etc. , Easier to use , Therefore, there is usually no need to write the above code manually .
import torch.optim as optim
optimizer = optim.SGD(net.parameters(), lr=0.01)
# In the training process, first clear the gradient ( And net.zero_grad() The effect is the same )
optimizer.zero_grad()
# Calculate the loss
output=net(input)
criterion = nn.MSELoss()
loss = criterion(output,target)
# Back propagation
loss.backward()
# Update parameters
optimizer.step()2. Data loading and preprocessing
torchvision The commonly used image data loading function is realized , for example Imagenet、CIFAR10、MNIST etc. , And common data conversion operations , Greatly facilitates data loading .
边栏推荐
- Hangao database best practice configuration tool Hg_ BP log collection content
- A case of gradually analyzing the splitting of classes -- colorful ball collisions
- Photo scale correction tool: DxO viewpoint 3 direct mount version
- Plato Farm在Elephant Swap上铸造的ePLATO是什么?为何具备高溢价?
- Kubernetes-1.24.x feature
- Singleton mode (hungry and lazy)
- 带你来浅聊一下,单商户功能模块汇总
- 今晚7:30 | 连界、将门、百度、碧桂园创投四位大佬眼中的AI世界,是继续高深还是回归商业本质?...
- Redis之sentinel哨兵集群怎么部署
- 3D高级渲染器:Artlantis studio 2021.2中文版
猜你喜欢

今晚7:30 | 连界、将门、百度、碧桂园创投四位大佬眼中的AI世界,是继续高深还是回归商业本质?...

Configure vscade to realize ROS writing

年内首个“三连跌” 95号汽油回归“8元时代“

NXP i.mx8mp-deepviewrt

Learn more than 4000 words, understand the problem of this pointing in JS, and handwrite to realize call, apply and bind

「PHP基础知识」输出圆周率的近似值

Rongyun real-time community solution

Photo scale correction tool: DxO viewpoint 3 direct mount version

Alibaba Sentinel - workflow and principle analysis
![[freeswitch development practice] unimrcp compilation and installation](/img/ef/b82326152326293bf98e89da28b887.png)
[freeswitch development practice] unimrcp compilation and installation
随机推荐
Does domestic ERP have a chance to beat sap?
How close can QA be to business code QA conducts testability transformation on business code
数字图像处理 第10章——图像分割
Asynchronous callback future mode of concurrent mode
12_ UE4 advanced_ Change a more beautiful character model
Alibaba Sentinel - workflow and principle analysis
[freeswitch development practice] media bug obtains call voice flow
2022-07-28 顾宇佳 学习笔记
【打开新世界大门】看测试老鸟如何把API 测试玩弄在鼓掌之间
Flask的创建的流程day05-06之创建项目
Plato Farm在Elephant Swap上铸造的ePLATO是什么?为何具备高溢价?
Typescript学习(一)
多行文本省略
Introduction and advanced MySQL (13)
今晚7:30 | 连界、将门、百度、碧桂园创投四位大佬眼中的AI世界,是继续高深还是回归商业本质?...
Watermelon book learning Chapter 6 -- SVM
Incremental real-time disaster recovery notes
Summary of basic knowledge points of C language
How does DataGrid export and recover the entire database data, using a single SQL file
[freeswitch development practice] unimrcp compilation and installation