You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

mindspore.nn.GELU.rst 1.2 kB

4 years ago
4 years ago
4 years ago
4 years ago
1234567891011121314151617181920212223242526272829303132333435363738
  1. mindspore.nn.GELU
  2. ==================
  3. .. py:class:: mindspore.nn.GELU(approximate=True)
  4. 高斯误差线性单元激活函数(Gaussian error linear unit activation function)。
  5. 对输入的每个元素计算GELU。
  6. GELU的定义如下:
  7. .. math::
  8. GELU(x_i) = x_i*P(X < x_i),
  9. 其中 :math:`P` 是标准高斯分布的累积分布函数, :math:`x_i` 是输入的元素。
  10. GELU相关图参见 `GELU <https://en.wikipedia.org/wiki/Activation_function#/media/File:Activation_gelu.png>`_ 。
  11. **参数:**
  12. **approximate** (bool): 是否启用approximation,默认值:True。如果approximate的值为True,则高斯误差线性激活函数为:
  13. :math:`0.5 * x * (1 + tanh(sqrt(2 / pi) * (x + 0.044715 * x^3)))` ,
  14. 否则为: :math:`x * P(X <= x) = 0.5 * x * (1 + erf(x / sqrt(2)))`, where P(X) ~ N(0, 1) 。
  15. **输入:**
  16. **x** (Tensor) - 用于计算GELU的Tensor。数据类型为float16或float32。shape是 :math:`(N,*)` , :math:`*` 表示任意的附加维度数。
  17. **输出:**
  18. Tensor,具有与 `x` 相同的数据类型和shape。
  19. **异常:**
  20. **TypeError** - `x` 的数据类型既不是float16也不是float32。