当前位置:网站首页>Learning notes [Gumbel softmax]
Learning notes [Gumbel softmax]
2022-07-01 19:24:00 【hei_ hei_ hei_】
gumbel softmax
Used for processing argmax Non differentiable case
Solutions : introduce gumbel Distribution . Use... In forward propagation argmax, Used in backward gradient return gumbel_softmax Calculation
Code
def gumbel_softmax(logits: Tensor, tau: float = 1, hard: bool = False, eps: float = 1e-10, dim: int = -1) -> Tensor:
...
gumbels = (
-torch.empty_like(logits, memory_format=torch.legacy_contiguous_format).exponential_().log()
) # ~Gumbel(0,1)
gumbels = (logits + gumbels) / tau # ~Gumbel(logits,tau)
y_soft = gumbels.softmax(dim)
if hard:
# Straight through.
index = y_soft.max(dim, keepdim=True)[1]
y_hard = torch.zeros_like(logits, memory_format=torch.legacy_contiguous_format).scatter_(dim, index, 1.0)
ret = y_hard - y_soft.detach() + y_soft
else:
# Reparametrization trick.
ret = y_soft
return ret
gumbel_softmax Temperature is introduced in t, t The smaller it is ,softmax The closer you get to One-hot. To train stability , commonly t Will take a larger number , Then gradually shrink .
The content is reproduced from gumbel softmax
边栏推荐
- Openai video pre training (VPT): action learning based on watching unmarked online videos
- Lake Shore—OptiMag 超导磁体系统 — OM 系列
- 记一次 .NET 差旅管理后台 CPU 爆高分析
- 线程的并行、并发、生命周期
- Mipi interface, DVP interface and CSI interface of camera [easy to understand]
- Boost the development of digital economy and consolidate the base of digital talents - the digital talent competition was successfully held in Kunming
- Write it down once Net travel management background CPU Explosion Analysis
- 机械设备行业数字化供应链集采平台解决方案:优化资源配置,实现降本增效
- [AGC] how to solve the problem that the local display of event analysis data is inconsistent with that in AGC panel?
- Lean thinking: source, pillar, landing. I understand it after reading this article
猜你喜欢
PMP是被取消了吗??
Altair HyperWorks 2022 software installation package and installation tutorial
[quick application] there are many words in the text component. How to solve the problem that the div style next to it will be stretched
Solution of digital supply chain centralized purchase platform in mechanical equipment industry: optimize resource allocation and realize cost reduction and efficiency increase
Intensive cultivation of channels for joint development Fuxin and Weishi Jiajie held a new product training conference
MySQL common graphics management tools | dark horse programmers
Solidity - 算术运算的截断模式(unchecked)与检查模式(checked)- 0.8.0新特性
小红书上的爱情买卖
水产行业智能供应链管理平台解决方案:支撑企业供应链数字化,提升企业管理效益
混沌工程平台 ChaosBlade-Box 新版重磅发布
随机推荐
Dlib+Opencv库实现疲劳检测
[quick application] win7 system cannot run and debug projects using Huawei ide
ECS summer money saving secret, this time @ old users come and take it away
How to operate technology related we media well?
Witness the times! "The future of Renji collaboration has come" 2022 Hongji ecological partnership conference opens live broadcast reservation
XML语法、约束
Go language self-study series | go language data type
一次SQL优化,数据库查询速度提升 60 倍
Three simple methods of ES6 array de duplication
Docker deploy mysql8.0
The difference between indexof and includes
【直播预约】数据库OBCP认证全面升级公开课
Implement a Prometheus exporter
Lake shore M91 fast hall measuring instrument
Solution: you can ping others, but others can't ping me
Bao, que se passe - t - il si le serveur 100 + O & M a mal à la tête? Utilisez le majordome xingyun!
Write it down once Net travel management background CPU Explosion Analysis
Viewing technological changes through Huawei Corps (VI): smart highway
Summary of cases of players' disconnection and reconnection in Huawei online battle service
Solution of digital supply chain centralized purchase platform in mechanical equipment industry: optimize resource allocation and realize cost reduction and efficiency increase