当前位置:网站首页>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

边栏推荐
- Niuke.com: minimum cost of climbing stairs
- Two methods for MySQL to open remote connection permission
- Raft介绍
- 中国传奇教授李泽湘,正在批量制造独角兽
- JS Es5 can also create constants?
- Good partner for cloud skill improvement, senior brother cloud of Amazon officially opened today
- 荣盛生物冲刺科创板:拟募资12.5亿 年营收2.6亿
- Dart: string replace related methods to solve replacement characters
- OpenCV中LineTypes各枚举值(LINE_4 、LINE_8 、LINE_AA )的含义
- jspreadsheet/CE JExcel数据字段比给的字段(columns)多会导致空白列的问题解决方案
猜你喜欢
![[BJDCTF2020]The mystery of ip|[CISCN2019 华东南赛区]Web11|SSTI注入](/img/c2/d6760826b81589781574aebff61f9a.png)
[BJDCTF2020]The mystery of ip|[CISCN2019 华东南赛区]Web11|SSTI注入

优惠券种类那么多,先区分清楚再薅羊毛!

MC Instruction Decoder

I implement "stack" with C I

Niuke: how many different binary search trees are there

Rong Lianyun launched rphone based on Tongxin UOS to create a new ecology of localization contact center

观测云与 TDengine 达成深度合作,优化企业上云体验

Symantec electronic sprint technology innovation board: Tan Jian, the actual controller, is an American who plans to raise 620million yuan

【Verilog基础】关于Clock信号的一些概念总结(clock setup/hold、clock tree、clock skew、clock latency、clock transition..)

名单揭晓 | 2021年度中国杰出知识产权服务团队
随机推荐
JS Es5 can also create constants?
go-micro教程 — 第一章 快速入门
Two methods for MySQL to open remote connection permission
In order to make remote work unaffected, I wrote an internal chat room | community essay
MySQL8.0开启远程连接权限的方法步骤
牛客网:有多少个不同的二叉搜索树
[machine learning] K-means clustering analysis
HMS Core音频编辑服务3D音频技术,助力打造沉浸式听觉盛宴
2022新消费半年盘点:行业遇冷,但这九个赛道依然吸金
CGR 21 (D,E,F)
KDD 2022 | how far are we from the general pre training recommendation model? Universal sequence representation learning model unisrec for recommender system
备战数学建模34-BP神经网络预测2
TCP Socket与TCP 连接
Siyuan notes: can you provide shortcut keys for folding all titles on the page?
Etcd教程 — 第九章 Etcd之实现分布式锁
halcon知识:区域专题【07】
Half year inventory of new consumption in 2022: the industry is cold, but these nine tracks still attract gold
2022 Blue Bridge Cup group B -2022- (01 backpack to calculate the number of schemes)
构建适合组织的云原生可观测性能力
Headhunter 50, 000, I'll go to VC