当前位置:网站首页>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
边栏推荐
- Nacos configuration file publishing failed, please check whether the parameters are correct solution
- 洞态在某互联⽹⾦融科技企业的最佳落地实践
- How to use the low code platform of the Internet of things for personal settings?
- MySQL common graphics management tools | dark horse programmers
- Huawei cloud experts explain the new features of gaussdb (for MySQL)
- Lake shore optimag superconducting magnet system om series
- Lake Shore低温恒温器的氦气传输线
- Altair HyperWorks 2022 software installation package and installation tutorial
- 记一次 .NET 差旅管理后台 CPU 爆高分析
- Lake Shore continuous flow cryostat transmission line
猜你喜欢

Specification of lumiprobe reactive dye indocyanine green

AI training speed breaks Moore's law; Song shuran's team won the RSS 2022 Best Paper Award

线程的并行、并发、生命周期

从零开始学 MySQL —数据库和数据表操作

MySQL common graphics management tools | dark horse programmers

智慧防疫系统为建筑工地复工复产提供安全保障

一次SQL优化,数据库查询速度提升 60 倍

【pytorch记录】自动混合精度训练 torch.cuda.amp

The market value evaporated by 74billion yuan, and the big man turned and entered the prefabricated vegetables

kubernetes命令入门(namespaces,pods)
随机推荐
C-end dream is difficult to achieve. What does iFLYTEK rely on to support the goal of 1billion users?
Cdga | if you are engaged in the communication industry, you should get a data management certificate
【快应用】Win7系统使用华为IDE无法运行和调试项目
Digital business cloud: from planning to implementation, how does Minmetals Group quickly build a new pattern of digital development?
记一次 .NET 差旅管理后台 CPU 爆高分析
一次SQL优化,数据库查询速度提升 60 倍
线程的并行、并发、生命周期
寶,運維100+服務器很頭疼怎麼辦?用行雲管家!
Huawei cloud experts explain the new features of gaussdb (for MySQL)
【AGC】如何解决事件分析数据本地和AGC面板中显示不一致的问题?
[live broadcast appointment] database obcp certification comprehensive upgrade open class
Technical secrets of ByteDance data platform: implementation and optimization of complex query based on Clickhouse
赋能「新型中国企业」,SAP Process Automation 落地中国
生鲜行业B2B电商平台解决方案,提高企业交易流程标准化和透明度
Lake Shore M91快速霍尔测量仪
SuperVariMag 超导磁体系统 — SVM 系列
Dom4J解析XML、Xpath检索XML
PMP是被取消了吗??
The intelligent epidemic prevention system provides safety guarantee for the resumption of work and production at the construction site
CDGA|从事通信行业,那你应该考个数据管理证书