!28701 optimize examples about HShrink and FastGelu

Merge pull request !28701 from chentangyu/code_docs_cty_master_I4PADY
This commit is contained in:
i-robot 2022-01-07 09:36:04 +00:00 committed by Gitee
commit 35ffa628eb
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 11 additions and 2 deletions

View File

@ -544,6 +544,9 @@ class FastGelu(Cell):
``Ascend``
Examples:
>>> import mindspore
>>> from mindspore import Tensor, nn
>>> import numpy as np
>>> x = Tensor(np.array([[-1.0, 4.0, -8.0], [2.0, -5.0, 9.0]]), mindspore.float32)
>>> fast_gelu = nn.FastGelu()
>>> output = fast_gelu(x)
@ -920,7 +923,10 @@ class HShrink(Cell):
TypeError: If dtype of `input_x` is neither float16 nor float32.
Examples:
>>> input_x = Tensor(np.array([[ 0.5, 1, 2.0],[0.0533,0.0776,-2.1233]]),mstype.float32)
>>> import mindspore
>>> from mindspore import Tensor, nn
>>> import numpy as np
>>> input_x = Tensor(np.array([[ 0.5, 1, 2.0],[0.0533,0.0776,-2.1233]]),mindspore.float32)
>>> hshrink = nn.HShrink()
>>> output = hshrink(input_x)
>>> print(output)

View File

@ -8604,7 +8604,10 @@ class HShrink(Primitive):
TypeError: If dtype of `input_x` is neither float16 nor float32.
Examples:
>>> input_x = Tensor(np.array([[ 0.5, 1, 2.0],[0.0533,0.0776,-2.1233]]),mstype.float32)
>>> import mindspore
>>> from mindspore import Tensor, nn
>>> import numpy as np
>>> input_x = Tensor(np.array([[ 0.5, 1, 2.0],[0.0533,0.0776,-2.1233]]),mindspore.float32)
>>> hshrink = P.HShrink()
>>> output = hshrink(input_x)
>>> print(output)