当前位置:网站首页>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
边栏推荐
- [time series database incluxdb] code example for configuring incluxdb+ data visualization and simple operation with C under Windows Environment
- [Verilog basics] octal and hexadecimal representation of decimal negative numbers
- I 用c I 实现“栈”
- RT thread heap size setting
- halcon知识:区域专题【07】
- On July 2, I invited you to TD Hero online conference
- How the edge computing platform helps the development of the Internet of things
- ArcMap operation series: 80 plane to latitude and longitude 84
- Bidding announcement: remote disaster recovery project of Shenzhen Finance Bureau database
- 八大基本排序(详解)
猜你喜欢
Etcd教程 — 第八章 Etcd之Compact、Watch和Lease API
中航无人机科创板上市:市值385亿 拳头产品是翼龙无人机
备战数学建模33-灰色预测模型2
【微信小程序】小程序的宿主环境
快照和备份
Etcd教程 — 第八章 Etcd之Compact、Watch和Lease API
There are so many kinds of coupons. First distinguish them clearly and then collect the wool!
备战数学建模36-时间序列模型2
[machine learning] K-means clustering analysis
Carry two load balancing notes and find them in the future
随机推荐
【机器学习】K-means聚类分析
中航无人机科创板上市:市值385亿 拳头产品是翼龙无人机
牛客网:最小花费爬楼梯
云技能提升好伙伴,亚马逊云师兄今天正式营业
腾讯二面:@Bean 与 @Component 用在同一个类上,会怎么样?
香港回归25周年 香港故宫博物馆正式开放成文化新地标
19:00 p.m. tonight, knowledge empowerment phase 2 live broadcast - control panel interface design of openharmony smart home project
招标公告:深圳市财政局数据库异地灾备项目
More dragon lizard self-developed features! Production available Anolis OS 8.6 officially released
mysql8报错:ERROR 1410 (42000): You are not allowed to create a user with GRANT解决办法
声网自研传输层协议 AUT 的落地实践丨Dev for Dev 专栏
IndexSearch
[Verilog basics] octal and hexadecimal representation of decimal negative numbers
Raft介绍
[BJDCTF2020]The mystery of ip|[CISCN2019 华东南赛区]Web11|SSTI注入
Lambda表达式_Stream流_File类
MySQL8.0开启远程连接权限的方法步骤
安全帽佩戴检测算法研究
搬运两个负载均衡的笔记,日后省的找
居家办公浅谈远程协助快速提效心得 | 社区征文