当前位置:网站首页>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
边栏推荐
- Viewing technological changes through Huawei Corps (VI): smart highway
- 线程的并行、并发、生命周期
- 【快应用】Win7系统使用华为IDE无法运行和调试项目
- 小红书上的爱情买卖
- How to operate technology related we media well?
- MATLAB中subplot函数的使用
- PostgreSQL varchar[] 数组类型操作
- 华为游戏初始化init失败,返回错误码907135000
- 论文泛读【FiLM: Visual Reasoning with a General Conditioning Layer】
- 案例分享:QinQ基本组网配置
猜你喜欢

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

More information about M91 fast hall measuring instrument

Lumiprobe cell imaging study PKH26 cell membrane labeling kit

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

Lake shore M91 fast hall measuring instrument
![[live broadcast appointment] database obcp certification comprehensive upgrade open class](/img/38/1ec382d0edda83d4052868255af9ea.jpg)
[live broadcast appointment] database obcp certification comprehensive upgrade open class

赋能「新型中国企业」,SAP Process Automation 落地中国
![[AGC] how to solve the problem that the local display of event analysis data is inconsistent with that in AGC panel?](/img/66/674a06d8e45a31ae879b81554ef373.png)
[AGC] how to solve the problem that the local display of event analysis data is inconsistent with that in AGC panel?

Today, with the popularity of micro services, how does service mesh exist?
![[pytorch record] automatic hybrid accuracy training torch cuda. amp](/img/a5/cf1eb2801380cf2887dfd532d3eb1e.jpg)
[pytorch record] automatic hybrid accuracy training torch cuda. amp
随机推荐
Lumiprobe 自由基分析丨H2DCFDA说明书
【pytorch记录】模型的分布式训练DataParallel、DistributedDataParallel
Three ways for redis to realize current limiting
Learning notes - steps of JDBC connection database operation
ETL development of data warehouse (IV)
Helium transmission line of lake shore cryostat
使用环信提供的uni-app Demo,快速实现一对一单聊
【Go ~ 0到1 】 第五天 7月1 类型别名,自定义类型,接口,包与初始化函数
Intensive cultivation of channels for joint development Fuxin and Weishi Jiajie held a new product training conference
智慧防疫系统为建筑工地复工复产提供安全保障
[AGC] how to solve the problem that the local display of event analysis data is inconsistent with that in AGC panel?
How to operate technology related we media well?
数商云:从规划到落地,五矿集团如何快速构建数字化发展新格局?
Lumiprobe 亚磷酰胺丨六甘醇亚磷酰胺说明书
Is PMP cancelled??
赋能「新型中国企业」,SAP Process Automation 落地中国
CDGA|从事通信行业,那你应该考个数据管理证书
Junit单元测试框架详解
VBA simple macro programming of Excel
华为游戏初始化init失败,返回错误码907135000