当前位置:网站首页>Deep learning - (2) several common loss functions
Deep learning - (2) several common loss functions
2022-06-30 16:48:00 【Pomelo flavored sheep】
Deep learning ——(2) Several common loss functions
List of articles
Great certainty , The smaller the entropy
Less certainty , The greater the entropy
1.L1 loss
advantage : The first derivative is Changshu
shortcoming : Non differentiable at zero
import torch
from torch import nn
criterion_l1=nn.L1Loss(reduction='mean')
input=torch.randn(3,5,requires_grad=True)
target=torch.randn(3,5)
loss_l1=criterion_l1(input,target)
# The calculation process
loss_l11=(abs(target-input)).sum()/15
loss_l1,loss_l11

2.MSEloss
Second order function
shortcoming : The gradient is very large , Will cause a gradient explosion ; After the derivation, the gradient will disappear
criterion_mse=nn.MSELoss()
loss_mse=criterion_mse(input,target)
# The calculation process
loss_mse1=((target-input)**2).sum()/15
loss_mse,loss_mse1

3.smoothL1 loss
advantage : Combined with the L1 and MSE The advantages of , Avoid zero point non derivative and gradient explosion
criterion_SML1=nn.SmoothL1Loss()
loss_sml1=criterion_SML1(input,target)
loss_sml1

4. Cross entropy loss
criterion_cross=nn.CrossEntropyLoss(reduction='mean',label_smoothing=0.0)
loss_cross=criterion_cross(input,target)
loss_cross

5.KL The divergence loss—— Relative entropy

criterion_KL=nn.KLDivLoss()
loss_KL=criterion_KL(input,target)
loss_KL

边栏推荐
- Cesium-1.72 learning (add points, lines, cubes, etc.)
- Mathematical modeling for war preparation 36 time series model 2
- Additional: (not written yet, don't look at ~ ~ ~) webmvcconfigurer interface;
- AVIC UAV technology innovation board is listed: the fist product with a market value of 38.5 billion is pterodactyl UAV
- Yunhe enmo won the bid for Oracle maintenance project of Tianjin Binhai rural commercial bank in 2022-2023
- Halcon knowledge: matrix topic [02]
- 2022 Blue Bridge Cup group B -2022- (01 backpack to calculate the number of schemes)
- Explain in detail the use of for loop, break and continue in go language
- [activity registration] it's your turn to explore the yuan universe! I will be waiting for you in Shenzhen on July 2!
- 几百行代码实现一个 JSON 解析器
猜你喜欢

7 月 2 日邀你来TD Hero 线上发布会

Niuke network: longest continuous subarray with positive product

八大基本排序(详解)

牛客网:有多少个不同的二叉搜索树

云技能提升好伙伴,亚马逊云师兄今天正式营业
Mysql8.0 method and steps for enabling remote connection permission
![[machine learning] K-means clustering analysis](/img/5f/3199fbd4ff2129d3e4ea518812c9e9.png)
[machine learning] K-means clustering analysis

居家办公浅谈远程协助快速提效心得 | 社区征文

AVIC UAV technology innovation board is listed: the fist product with a market value of 38.5 billion is pterodactyl UAV

华为帐号多端协同,打造美好互联生活
随机推荐
[activity registration] it's your turn to explore the yuan universe! I will be waiting for you in Shenzhen on July 2!
MySQL开放远程连接权限的两种方法
2020 Blue Bridge Cup group B - move bricks - (greedy sorting +01 backpack)
What is the difference between real-time rendering and pre rendering
microblaze 串口学习·2
Good partner for cloud skill improvement, senior brother cloud of Amazon officially opened today
Dart: string replace related methods to solve replacement characters
More dragon lizard self-developed features! Production available Anolis OS 8.6 officially released
2022 Blue Bridge Cup group B - expense reimbursement - (linear dp| status DP)
halcon知识:矩阵专题【02】
Implementation of Devops in the core field of qunar, the Internet R & D Efficiency
Interpretation of gaussdb's innovative features: partial result cache accelerates operators by caching intermediate results
mysql8报错:ERROR 1410 (42000): You are not allowed to create a user with GRANT解决办法
RTP 发送PS流零拷贝方案
药品管理系统加数据库,一夜做完,加报告
Observation cloud reached in-depth cooperation with tdengine to optimize enterprise cloud experience
附加:(还没写,别看~~~)WebMvcConfigurer接口;
IndexSearch
附加:(还没写,别看~~~)CorsFilter过滤器;
CMakeLists 基础