当前位置:网站首页>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
边栏推荐
- MFC中如何重绘CListCtrl的表头
- 数商云:从规划到落地,五矿集团如何快速构建数字化发展新格局?
- 【森城市】GIS数据漫谈(一)
- Manufacturing SRM management system supplier all-round closed-loop management, to achieve procurement sourcing and process efficient collaboration
- 3. "Create your own NFT collections and publish a Web3 application to show them" cast NFT locally
- 【6.24-7.1】写作社区精彩技术博文回顾
- 组队学习! 14天鸿蒙设备开发“学练考”实战营限时免费加入!
- Solidity - 算术运算的截断模式(unchecked)与检查模式(checked)- 0.8.0新特性
- Chinese and English instructions human soluble advanced glycation end products receptor (sRAGE) ELISA Kit
- Lumiprobe 活性染料丨吲哚菁绿说明书
猜你喜欢

Lumiprobe 亚磷酰胺丨六甘醇亚磷酰胺说明书

Dom4J解析XML、Xpath检索XML

Getting started with kubernetes command (namespaces, pods)

B2B e-commerce platform solution for fresh food industry to improve the standardization and transparency of enterprise transaction process

C端梦难做,科大讯飞靠什么撑起10亿用户目标?

Lake Shore continuous flow cryostat transmission line

Lumiprobe cell imaging study PKH26 cell membrane labeling kit

Lumiprobe free radical analysis h2dcfda instructions
使用环信提供的uni-app Demo,快速实现一对一单聊

Witness the times! "The future of Renji collaboration has come" 2022 Hongji ecological partnership conference opens live broadcast reservation
随机推荐
Viewing the whole ecology of Tiktok from a macro perspective
洞态在某互联⽹⾦融科技企业的最佳落地实践
Once the SQL is optimized, the database query speed is increased by 60 times
[6.24-7.1] review of wonderful technical blog posts in the writing community
【AGC】如何解决事件分析数据本地和AGC面板中显示不一致的问题?
Contos 7 搭建sftp之创建用户、用户组以及删除用户
Lumiprobe 活性染料丨吲哚菁绿说明书
寶,運維100+服務器很頭疼怎麼辦?用行雲管家!
助力数字经济发展,夯实数字人才底座—数字人才大赛在昆成功举办
Clean up system cache and free memory under Linux
Lake Shore - crx-em-hf low temperature probe station
The former 4A executives engaged in agent operation and won an IPO
论文阅读【Learning to Discretely Compose Reasoning Module Networks for Video Captioning】
CDGA|从事通信行业,那你应该考个数据管理证书
The market value evaporated by 74billion yuan, and the big man turned and entered the prefabricated vegetables
Team up to learn! 14 days of Hongmeng equipment development "learning, practicing and testing" practical camp, free of charge!
C端梦难做,科大讯飞靠什么撑起10亿用户目标?
Netease games, radical going to sea
Implement a Prometheus exporter
Improve yolov5 with gsconv+slim neck to maximize performance!