forked from mindspore-Ecosystem/mindspore
add examples of core and clip_by_value operator.
This commit is contained in:
parent
1dffd25432
commit
036c381832
|
@ -75,6 +75,15 @@ def core(fn=None, **flags):
|
||||||
fn (Function): Function to add flag. Default: None.
|
fn (Function): Function to add flag. Default: None.
|
||||||
flags (dict): The following flags can be set core, which indicates that this is a core function or
|
flags (dict): The following flags can be set core, which indicates that this is a core function or
|
||||||
other flag. Default: None.
|
other flag. Default: None.
|
||||||
|
|
||||||
|
Supported Platforms:
|
||||||
|
``Ascend`` ``GPU``
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
>>> net = Net()
|
||||||
|
>>> net = core(net, predit=True)
|
||||||
|
>>> print(hasattr(net, '_mindspore_flags'))
|
||||||
|
True
|
||||||
"""
|
"""
|
||||||
# need set the attr and access on c++
|
# need set the attr and access on c++
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,22 @@ def clip_by_value(x, clip_value_min, clip_value_max):
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Tensor, a clipped Tensor.
|
Tensor, a clipped Tensor.
|
||||||
|
|
||||||
|
Supported Platforms:
|
||||||
|
``Ascend`` ``GPU``
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
>>> import numpy as np
|
||||||
|
>>> from mindspore import Tensor
|
||||||
|
>>> from mindspore.ops import composite as C
|
||||||
|
>>> import mindspore.common.dtype as mstype
|
||||||
|
>>> min_value = Tensor(5, mstype.float32)
|
||||||
|
>>> max_value = Tensor(20, mstype.float32)
|
||||||
|
>>> x = Tensor(np.array([[1., 25., 5., 7.], [4., 11., 6., 21.]]), mstype.float32)
|
||||||
|
>>> output = C.clip_by_value(x, min_value, max_value)
|
||||||
|
>>> print(output)
|
||||||
|
[[ 5. 20. 5. 7.]
|
||||||
|
[ 5. 11. 6. 20.]]
|
||||||
"""
|
"""
|
||||||
min_op = P.Minimum()
|
min_op = P.Minimum()
|
||||||
max_op = P.Maximum()
|
max_op = P.Maximum()
|
||||||
|
|
Loading…
Reference in New Issue