当前位置:网站首页>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
边栏推荐
- 微服务大行其道的今天,Service Mesh是怎样一种存在?
- Graduation season | Huawei experts teach the interview secret: how to get a high paying offer from a large factory?
- Dom4J解析XML、Xpath检索XML
- 组队学习! 14天鸿蒙设备开发“学练考”实战营限时免费加入!
- 赋能「新型中国企业」,SAP Process Automation 落地中国
- 有关 M91 快速霍尔测量仪的更多信息
- Nacos configuration file publishing failed, please check whether the parameters are correct solution
- 宝,运维100+服务器很头疼怎么办?用行云管家!
- 【直播预约】数据库OBCP认证全面升级公开课
- Once the SQL is optimized, the database query speed is increased by 60 times
猜你喜欢

见证时代!“人玑协同 未来已来”2022弘玑生态伙伴大会开启直播预约

前4A高管搞代运营,拿下一个IPO

华为游戏初始化init失败,返回错误码907135000

MATLAB中subplot函数的使用

【AGC】如何解决事件分析数据本地和AGC面板中显示不一致的问题?

kubernetes命令入门(namespaces,pods)

洞态在某互联⽹⾦融科技企业的最佳落地实践

Enabling "new Chinese enterprises", SAP process automation landing in China

Dlib+Opencv库实现疲劳检测

Specification of lumiprobe reactive dye indocyanine green
随机推荐
Dlib+Opencv库实现疲劳检测
Chaos engineering platform chaosblade box new heavy release
PMP是被取消了吗??
有关 M91 快速霍尔测量仪的更多信息
宝,运维100+服务器很头疼怎么办?用行云管家!
Specification of lumiprobe reactive dye indocyanine green
SuperOptiMag 超导磁体系统 — SOM、SOM2 系列
Solidity - 合约结构 - 错误(error)- ^0.8.4版本新增
nacos配置文件发布失败,请检查参数是否正确的解决方案
Lake Shore—CRX-EM-HF 型低温探针台
Solution of intelligent supply chain management platform in aquatic industry: support the digitalization of enterprise supply chain and improve enterprise management efficiency
kubernetes命令入门(namespaces,pods)
CDGA|从事通信行业,那你应该考个数据管理证书
Lumiprobe 细胞成像研究丨PKH26细胞膜标记试剂盒
使用环信提供的uni-app Demo,快速实现一对一单聊
indexof和includes的区别
Technical secrets of ByteDance data platform: implementation and optimization of complex query based on Clickhouse
More information about M91 fast hall measuring instrument
Once the SQL is optimized, the database query speed is increased by 60 times
Summary of cases of players' disconnection and reconnection in Huawei online battle service