当前位置:网站首页>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 .
边栏推荐
- Example analysis of while, repeat and loop loops in MySQL process control
- How does DataGrid export and recover the entire database data, using a single SQL file
- MYSQL入门与进阶(十二)
- Redis configuration cache expiration listening event trigger
- 2. Nodejs -- path (\dirname, \filname), URL URL, querystring module, mime module, various paths (relative paths), web page loading (interview questions *)
- xxxxx
- Reproduce 20 character short domain name bypass and XSS related knowledge points
- 增量实时灾备笔记
- Sanzi chess (player + computer)
- Several methods of converting object to string
猜你喜欢

数字图像处理 第10章——图像分割

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

Summarize the knowledge points of the ten JVM modules. If you don't believe it, you still don't understand it

makefile详解

MYCAT read / write separation configuration

01-sdram: Code of initialization module

mycat读写分离配置

How does DataGrid export and recover the entire database data, using a single SQL file

Tp5.0 applet users do not need to log in and directly obtain the user's mobile number.

国产ERP有没有机会击败SAP ?
随机推荐
STC单片机驱动1.8‘TFT SPI屏幕演示示例(含资料包)
MYSQL入门与进阶(十三)
Redis configuration cache expiration listening event trigger
SAP 中国本地化内容汇总
后缀自动机(sam)板子 from jly
Design of smoke temperature, humidity and formaldehyde monitoring based on single chip microcomputer
2.nodejs--路径(_dirname,_filname)、url网址、querystring模块、mime模块、各种路径(相对路径)、网页的加载(面试题*)
Detailed steps for installing MySQL 8.0 under Linux
Unity game special effects
Data truncation and estimation
C traps and defects Chapter 3 semantic "traps" 3.1 pointers and arrays
腾讯云使用pem登录
反脆弱·从不确定性中获益---管理?
shell脚本总结
xxxxx
增量实时灾备笔记
2022-07-28 第四小组 修身课 学习笔记(every day)
[robot learning] matlab kinematics and ADMAS dynamics analysis of manipulator gripper
C language programming | exchange binary odd and even bits (macro Implementation)
How does DataGrid export and recover the entire database data, using a single SQL file