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

边栏推荐
- Bidding announcement: Taizhou Unicom Oracle all in one machine and database maintenance service project in 2022
- TCP Socket与TCP 连接
- [BJDCTF2020]The mystery of ip|[CISCN2019 华东南赛区]Web11|SSTI注入
- 7 月 2 日邀你来TD Hero 线上发布会
- [activity registration] it's your turn to explore the yuan universe! I will be waiting for you in Shenzhen on July 2!
- 居家办公浅谈远程协助快速提效心得 | 社区征文
- 备战数学建模36-时间序列模型2
- 为了使远程工作不受影响,我写了一个内部的聊天室 | 社区征文
- go-zero微服务实战系列(八、如何处理每秒上万次的下单请求)
- 名单揭晓 | 2021年度中国杰出知识产权服务团队
猜你喜欢

Headhunter 50, 000, I'll go to VC

Cesium-1.72 learning (earth model creation online offline tile)

备战数学建模34-BP神经网络预测2

Go zero micro Service Practice Series (VIII. How to handle tens of thousands of order requests per second)

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

Home office discussion on the experience of remote assistance to quickly improve efficiency | community essay solicitation

Mathematical modeling for war preparation 36 time series model 2

There are so many kinds of coupons. First distinguish them clearly and then collect the wool!

Raft介绍

Niuke: how many different binary search trees are there
随机推荐
Headhunter 50, 000, I'll go to VC
容联云首发基于统信UOS的Rphone,打造国产化联络中心新生态
Niuke network: longest continuous subarray with positive product
How the edge computing platform helps the development of the Internet of things
GaussDB创新特性解读:Partial Result Cache,通过缓存中间结果对算子进行加速
构建适合组织的云原生可观测性能力
Mathematical modeling for war preparation 33- grey prediction model 2
[Verilog basics] octal and hexadecimal representation of decimal negative numbers
Cesium-1.72 learning (add points, lines, cubes, etc.)
MySQL transaction / lock / log summary
荣盛生物冲刺科创板:拟募资12.5亿 年营收2.6亿
Yunhe enmo won the bid for Oracle maintenance project of Tianjin Binhai rural commercial bank in 2022-2023
药品管理系统加数据库,一夜做完,加报告
八大基本排序(详解)
TCP Socket与TCP 连接
【Verilog基础】十进制负数的八进制、十六进制表示
I 用c I 实现“栈”
牛客网:最小花费爬楼梯
9:第三章:电商工程分析:4:【通用模块】;(待写……)
How to get the preferential activities for stock account opening? Is online account opening safe?