当前位置:网站首页>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
- transform + asm资料
- M91快速霍尔测量仪—在更短的时间内进行更好的测量
- Lake shore optimag superconducting magnet system om series
- 网易游戏,激进出海
- Graduation summary
- 制造业SRM管理系统供应商全方位闭环管理,实现采购寻源与流程高效协同
- DTD建模
- Summary of the core steps in the life cycle of beans
- VBA simple macro programming of Excel
猜你喜欢
随机推荐
AI training speed breaks Moore's law; Song shuran's team won the RSS 2022 Best Paper Award
kubernetes命令入门(namespaces,pods)
Netease games, radical going to sea
Lumiprobe free radical analysis h2dcfda instructions
水产行业智能供应链管理平台解决方案:支撑企业供应链数字化,提升企业管理效益
Love business in Little Red Book
transform + asm资料
Lumiprobe 细胞成像研究丨PKH26细胞膜标记试剂盒
CDGA|从事通信行业,那你应该考个数据管理证书
Clean up system cache and free memory under Linux
How to use the low code platform of the Internet of things for personal settings?
MySQL common graphics management tools | dark horse programmers
MFC中如何重绘CListCtrl的表头
Solution of intelligent supply chain management platform in aquatic industry: support the digitalization of enterprise supply chain and improve enterprise management efficiency
云服务器ECS夏日省钱秘籍,这次@老用户快来领走
Lumiprobe phosphide hexaethylene phosphide specification
Nacos configuration file publishing failed, please check whether the parameters are correct solution
English语法_形容词/副词3级 -注意事项
How to operate technology related we media well?
Lake Shore M91快速霍尔测量仪








