当前位置:网站首页>深度学习——(2)几种常见的损失函数
深度学习——(2)几种常见的损失函数
2022-06-30 15:48:00 【柚子味的羊】
深度学习——(2)几种常见的损失函数
文章目录
确定性大,熵越小
确定性小,熵越大
1.L1 loss
优点:一阶导是常熟
缺点:零点处不可导
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)
#计算过程
loss_l11=(abs(target-input)).sum()/15
loss_l1,loss_l11

2.MSEloss
二阶函数
缺点:梯度很大,会导致梯度爆炸;求导之后会存在梯度消失的现象
criterion_mse=nn.MSELoss()
loss_mse=criterion_mse(input,target)
#计算过程
loss_mse1=((target-input)**2).sum()/15
loss_mse,loss_mse1

3.smoothL1 loss
优点:结合了L1和MSE的优点,避免零点不可导以及梯度爆炸的状况
criterion_SML1=nn.SmoothL1Loss()
loss_sml1=criterion_SML1(input,target)
loss_sml1

4. 交叉熵 loss
criterion_cross=nn.CrossEntropyLoss(reduction='mean',label_smoothing=0.0)
loss_cross=criterion_cross(input,target)
loss_cross

5.KL散度loss——相对熵

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

边栏推荐
- go-zero微服务实战系列(八、如何处理每秒上万次的下单请求)
- RT-Thread 堆區大小設置
- 牛客网:乘积为正数的最长连续子数组
- 【活动报名】探秘元宇宙,就差你了!7月2号我在深圳现场等你!
- Go zero micro Service Practice Series (VIII. How to handle tens of thousands of order requests per second)
- 猎头5万挖我去VC
- 【牛客网刷题系列 之 Verilog快速入门】~ 位拆分与运算
- [download attached] installation and use of penetration test artifact Nessus
- What are the reasons for the errors reported by the Flink SQL CDC synchronization sqlserver
- Anaconda下安装Jupyter notebook
猜你喜欢

go-zero微服务实战系列(八、如何处理每秒上万次的下单请求)

新茶饮“死去活来”,供应商却“盆满钵满”?

JS Es5 can also create constants?

The inspiration from infant cognitive learning may be the key to the next generation of unsupervised machine learning

Wechat emoticons are written into the judgment, and the OK and bomb you send may become "testimony in court"

【微信小程序】常用组件基本使用(view/scroll-view/swiper、text/rich-text、button/image)

安全帽佩戴检测算法研究

华为帐号多端协同,打造美好互联生活

CVPR 2022 - Tesla AI proposed: generalized pedestrian re recognition based on graph sampling depth metric learning

Carry two load balancing notes and find them in the future
随机推荐
Yunhe enmo won the bid for Oracle maintenance project of Tianjin Binhai rural commercial bank in 2022-2023
Carry two load balancing notes and find them in the future
Unsupported major. minor version 52.0
Create statement for Oracle export view
Niuke network: longest continuous subarray with positive product
19:00 p.m. tonight, knowledge empowerment phase 2 live broadcast - control panel interface design of openharmony smart home project
What are the reasons for the errors reported by the Flink SQL CDC synchronization sqlserver
Bidding announcement: Tianjin housing provident fund management center database all-in-one machine and database software project (budget: 6.45 million)
MC Instruction Decoder
[Verilog quick start of Niuke online question series] ~ bit splitting and operation
牛客网:乘积为正数的最长连续子数组
更多龙蜥自研特性!生产可用的 Anolis OS 8.6 正式发布
几百行代码实现一个 JSON 解析器
CVPR 2022 - Tesla AI proposed: generalized pedestrian re recognition based on graph sampling depth metric learning
安全帽佩戴检测算法研究
思源笔记:能否提供页面内折叠所有标题的快捷键?
Interpretation of gaussdb's innovative features: partial result cache accelerates operators by caching intermediate results
2022蓝桥杯国赛B组-2022-(01背包求方案数)
Mathematical modeling for war preparation 36 time series model 2
OpenCV中LineTypes各枚举值(LINE_4 、LINE_8 、LINE_AA )的含义