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.ops.GeLU.rst 1.2 kB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. mindspore.ops.GeLU
  2. ==================
  3. .. py:class:: mindspore.ops.GeLU(*args, **kwargs)
  4. 高斯误差线性单元激活函数(Gaussian Error Linear Units activation function)。
  5. `Gaussian Error Linear Units (GELUs) <https://arxiv.org/abs/1606.08415>`_ 描述了GeLU函数。
  6. 此外,也可以参考 `BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding <https://arxiv.org/abs/1810.04805>`_ 。
  7. GeLU函数定义如下:
  8. .. math::
  9. \text{output} = 0.5 * x * (1 + tanh(x / \sqrt{2})),
  10. 其中 :math:`tanh` 是双曲正切函数。
  11. **输入:**
  12. - **x** (Tensor) - 用于计算GeLU函数的Tensor,数据类型为float16或float32。
  13. **输出:**
  14. Tensor,数据类型和shape与 `x` 的相同。
  15. **异常:**
  16. - **TypeError** - `x` 不是Tensor。
  17. - **TypeError** - `x` 的数据类型既不是float16也不是float32。
  18. **支持平台:**
  19. ``Ascend`` ``GPU`` ``CPU``
  20. **样例:**
  21. >>> x = Tensor(np.array([1.0, 2.0, 3.0]), mindspore.float32)
  22. >>> gelu = ops.GeLU()
  23. >>> result = gelu(x)
  24. >>> print(result)
  25. [0.841192 1.9545976 2.9963627]