概念-激活函数.pytorch实现

Non-linear Activations (weighted sum, nonlinearity)

激活函数 简介 图示
nn.ELU Exponential Linear Unit (ELU) function, element-wise. image
nn.Hardshrink Hard Shrinkage (Hardshrink) function element-wise. image
nn.Hardsigmoid Hardsigmoid function element-wise. image
nn.Hardtanh HardTanh function element-wise. image
nn.Hardswish Hardswish function, element-wise. image
nn.LeakyReLU LeakyReLU function element-wise. image
nn.LogSigmoid Logsigmoid function element-wise. image
nn.MultiheadAttention Allows the model to jointly attend to information from different representation subspaces. image
nn.PReLU element-wise PReLU function. image
nn.ReLU rectified linear unit function element-wise. image
nn.ReLU6 ReLU6 function element-wise. image
nn.RReLU randomized leaky rectified linear unit function, element-wise. image
nn.SELU SELU function element-wise. image
nn.CELU CELU function element-wise. image
nn.GELU Gaussian Error Linear Units function. image
nn.Sigmoid Sigmoid function element-wise. image
nn.SiLU Sigmoid Linear Unit (SiLU) function, element-wise. image
nn.Mish Mish function, element-wise. image
nn.Softplus Softplus function element-wise. image
nn.Softshrink soft shrinkage function element-wise. image
nn.Softsign element-wise Softsign function. image
nn.Tanh Hyperbolic Tangent (Tanh) function element-wise. image
nn.Tanhshrink element-wise Tanhshrink function. image
nn.Threshold Thresholds each element of the input Tensor. $\begin{cases} x & x >Threshold\ value & otherwise \end{cases}$
nn.GLU gated linear unit function. 输入矩阵根据输入参数分割成两个子矩阵a和b,计算矩阵 a *b

Non-linear Activations (other)

激活函数 简介 说明
nn.Softmin Applies the Softmin function to an n-dimensional input Tensor. 重新缩放输入的n维张量,使输出 Tensor 的元素位于 [0,1] 范围内且总和为 1(每个dim指定方向的切片综合)。softmin 是单调递减(最小的数在经过了softmin后变成最大值)
nn.Softmax Applies the Softmax function to an n-dimensional input Tensor. 重新缩放输入的n维张量,使输出 Tensor 的元素位于 [0,1] 范围内且总和为 1(每个dim指定方向的切片综合)。softmax 是单调递增(操作会使得最大的值在激活操作后依然保持最大
nn.Softmax2d Applies SoftMax over features to each spatial location. SoftMax 应用到每个空间位置的要素上。不再是dim指定的切片方向,而是整个输入张量
nn.LogSoftmax Applies the $log⁡(Softmax(x)) $function to an n-dimensional input Tensor. SoftMax 应用到输入的n维张量后,对结果再取$log$
nn.AdaptiveLogSoftmaxWithLoss Applies the $log⁡(Softmax(x))$ function to an n-dimensional input Tensor. 作为输入传递到该模块的标签应根据其频率进行排序,并在排序后根据指定的数目对输入的标签进行分簇处理。
-------------本文结束感谢您的阅读-------------