当前位置:网站首页>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 .
边栏推荐
- Minesweeping simple version
- 美联储再加息,75基点 鲍威尔“放鸽”,美股狂欢
- Producer consumer model of concurrent model
- Regular expression bypasses WAF
- Summary of basic knowledge points of C language
- 基于单片机烟雾温湿度甲醛监测设计
- SAP 中国本地化内容汇总
- MYCAT read / write separation configuration
- Score addition and subtraction of force deduction and brushing questions (one question per day 7/27)
- July 28, 2022 Gu Yujia's study notes
猜你喜欢

01-sdram: Code of initialization module

Flask的创建的流程day05-06之创建项目

Hangao database best practice configuration tool Hg_ BP log collection content

Mathematical modeling -- analytic hierarchy process model

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

mysql的timestamp存在的时区问题怎么解决

复现20字符短域名绕过以及xss相关知识点

July 28, 2022 Gu Yujia's study notes

Digital image processing Chapter 10 - image segmentation

How to deploy sentinel cluster of redis
随机推荐
makefile详解
MySQL流程控制之while、repeat、loop循环实例分析
Makefile details
Typescript学习(一)
2022-07-28 study notes of group 4 self-cultivation class (every day)
Regular expression bypasses WAF
Bingbing learning notes: operator overloading -- implementation of date class
2. Nodejs -- path (\dirname, \filname), URL URL, querystring module, mime module, various paths (relative paths), web page loading (interview questions *)
Summary of basic knowledge points of C language
【打开新世界大门】看测试老鸟如何把API 测试玩弄在鼓掌之间
简历竟然敢写精通并发编程,那你说说AQS为什么要用双向链表?
C obtains JSON format data asynchronously from the web address
Photo scale correction tool: DxO viewpoint 3 direct mount version
Flask的创建的流程day05-06之创建项目
Asynchronous callback future mode of concurrent mode
腾讯云使用pem登录
2022-07-28 第四小组 修身课 学习笔记(every day)
Three military product baselines (functional baseline, distribution baseline, product baseline) and the documents contained in the baseline
逐步分析类的拆分之案例——五彩斑斓的小球碰撞
HDU多校第二场 1011 DOS Card