speechbrain.nnet.activations 模块
实现激活函数的库。
- Authors
Mirco Ravanelli 2020
钟建元 2020
摘要
类:
从Gumbel-Softmax分布中采样并可选地离散化。 |
|
计算2D、3D或4D输入张量的softmax。 |
|
该类实现了来自https://arxiv.org/pdf/2005.03191.pdf的Swish激活函数 |
参考
- class speechbrain.nnet.activations.Softmax(apply_log=False, dim=-1, reshape=True, dtype=torch.float32)[source]
基础:
Module计算2D、3D或4D输入张量的softmax。
- Parameters:
Example
>>> classifier = Softmax() >>> inputs = torch.rand(10, 50, 40) >>> output = classifier(inputs) >>> output.shape torch.Size([10, 50, 40])
- class speechbrain.nnet.activations.GumbelSoftmax(tau, hard=False, apply_log=False)[source]
基础:
Module从Gumbel-Softmax分布中采样,并可选择离散化。
参考:https://arxiv.org/abs/1611.00712, https://arxiv.org/abs/1611.01144
- Parameters:
Example
>>> x = torch.randn((8, 40, 120)) >>> act = GumbelSoftmax(0.8, True) >>> x = act(x)
- class speechbrain.nnet.activations.Swish(beta: float = 1.0)[source]
基础:
Module该类实现了来自https://arxiv.org/pdf/2005.03191.pdf的Swish激活函数
给定输入 x。Swish(x) = x / (1 + exp(beta * x))
- Parameters:
beta (float) – Beta 值。
Example
>>> x = torch.randn((8, 40, 120)) >>> act = Swish() >>> x = act(x)