Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
正统之独孤求败
mindspore
提交
50ed76bc
M
mindspore
项目概览
正统之独孤求败
/
mindspore
与 Fork 源项目一致
Fork自
MindSpore / mindspore
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
mindspore
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
50ed76bc
编写于
4月 13, 2020
作者:
G
guohongzilong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
unify some examples in mindpore front
上级
c75f75a3
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
21 addition
and
21 deletion
+21
-21
mindspore/nn/layer/normalization.py
mindspore/nn/layer/normalization.py
+1
-1
mindspore/nn/layer/pooling.py
mindspore/nn/layer/pooling.py
+2
-2
mindspore/nn/loss/loss.py
mindspore/nn/loss/loss.py
+1
-1
mindspore/nn/metrics/__init__.py
mindspore/nn/metrics/__init__.py
+1
-1
mindspore/nn/metrics/error.py
mindspore/nn/metrics/error.py
+1
-1
mindspore/ops/operations/control_ops.py
mindspore/ops/operations/control_ops.py
+3
-3
mindspore/ops/operations/math_ops.py
mindspore/ops/operations/math_ops.py
+2
-2
mindspore/ops/operations/nn_ops.py
mindspore/ops/operations/nn_ops.py
+3
-3
mindspore/ops/operations/other_ops.py
mindspore/ops/operations/other_ops.py
+6
-6
mindspore/ops/operations/random_ops.py
mindspore/ops/operations/random_ops.py
+1
-1
未找到文件。
mindspore/nn/layer/normalization.py
浏览文件 @
50ed76bc
...
...
@@ -256,7 +256,7 @@ class LayerNorm(Cell):
Tensor, the normalized and scaled offset tensor, has the same shape and data type as the `input_x`.
Examples:
>>> x = Tensor(np.ones([20, 5, 10, 10]
, np.float32)
)
>>> x = Tensor(np.ones([20, 5, 10, 10]
), mindspore.float32
)
>>> shape1 = x.shape()[1:]
>>> m = nn.LayerNorm(shape1, begin_norm_axis=1, begin_params_axis=1)
>>> m(x)
...
...
mindspore/nn/layer/pooling.py
浏览文件 @
50ed76bc
...
...
@@ -104,7 +104,7 @@ class MaxPool2d(_PoolNd):
Tensor of shape :math:`(N, C_{out}, H_{out}, W_{out})`.
Examples:
>>> pool = MaxPool2d(kernel_size=3, stride=1)
>>> pool =
nn.
MaxPool2d(kernel_size=3, stride=1)
>>> x = Tensor(np.random.randint(0, 10, [1, 2, 4, 4]), mindspore.float32)
[[[[1. 5. 5. 1.]
[0. 3. 4. 8.]
...
...
@@ -186,7 +186,7 @@ class AvgPool2d(_PoolNd):
Tensor of shape :math:`(N, C_{out}, H_{out}, W_{out})`.
Examples:
>>> pool = AvgPool2d(kernel_size=3, strides=1)
>>> pool =
nn.
AvgPool2d(kernel_size=3, strides=1)
>>> x = Tensor(np.random.randint(0, 10, [1, 2, 4, 4]), mindspore.float32)
[[[[5. 5. 9. 9.]
[8. 4. 3. 0.]
...
...
mindspore/nn/loss/loss.py
浏览文件 @
50ed76bc
...
...
@@ -284,7 +284,7 @@ class SoftmaxCrossEntropyExpand(Cell):
Tensor, a scalar tensor including the mean loss.
Examples:
>>> loss = SoftmaxCrossEntropyExpand(sparse=True)
>>> loss =
nn.
SoftmaxCrossEntropyExpand(sparse=True)
>>> input_data = Tensor(np.ones([64, 512]), dtype=mindspore.float32)
>>> label = Tensor(np.ones([64]), dtype=mindspore.int32)
>>> loss(input_data, label)
...
...
mindspore/nn/metrics/__init__.py
浏览文件 @
50ed76bc
...
...
@@ -83,7 +83,7 @@ def get_metric_fn(name, *args, **kwargs):
Metric object, class instance of the metric method.
Examples:
>>> metric = get_metric_fn('precision', eval_type='classification')
>>> metric =
nn.
get_metric_fn('precision', eval_type='classification')
"""
if
name
not
in
__factory__
:
raise
KeyError
(
"Unknown Metric:"
,
name
)
...
...
mindspore/nn/metrics/error.py
浏览文件 @
50ed76bc
...
...
@@ -97,7 +97,7 @@ class MSE(Metric):
Examples:
>>> x = Tensor(np.array([0.1, 0.2, 0.6, 0.9]), mindspore.float32)
>>> y = Tensor(np.array([0.1, 0.25, 0.5, 0.9]), mindspore.float32)
>>> error = MSE()
>>> error =
nn.
MSE()
>>> error.clear()
>>> error.update(x, y)
>>> result = error.eval()
...
...
mindspore/ops/operations/control_ops.py
浏览文件 @
50ed76bc
...
...
@@ -51,9 +51,9 @@ class ControlDepend(Primitive):
>>> class Net(nn.Cell):
>>> def __init__(self):
>>> super(Net, self).__init__()
>>> self.global_step = Parameter(initializer(0, [1]), name="global_step")
>>> self.global_step =
mindspore.
Parameter(initializer(0, [1]), name="global_step")
>>> self.rate = 0.2
>>> self.control_depend = ControlDepend()
>>> self.control_depend =
P.
ControlDepend()
>>>
>>> def construct(self, x):
>>> data = self.rate * self.global_step + x
...
...
@@ -92,7 +92,7 @@ class GeSwitch(PrimitiveWithInfer):
>>> super(Net, self).__init__()
>>> self.square = P.Square()
>>> self.add = P.TensorAdd()
>>> self.value = Tensor(np.full((1), 3
, dtype=np.float32)
)
>>> self.value = Tensor(np.full((1), 3
), mindspore.float32
)
>>> self.switch = P.GeSwitch()
>>> self.merge = P.Merge()
>>> self.less = P.Less()
...
...
mindspore/ops/operations/math_ops.py
浏览文件 @
50ed76bc
...
...
@@ -133,7 +133,7 @@ class AssignAdd(PrimitiveWithInfer):
>>> def __init__(self):
>>> super(Net, self).__init__()
>>> self.AssignAdd = P.AssignAdd()
>>> self.variable = Parameter(initializer(1, [1], mindspore.int64), name="global_step")
>>> self.variable =
mindspore.
Parameter(initializer(1, [1], mindspore.int64), name="global_step")
>>>
>>> def construct(self, x):
>>> self.AssignAdd(self.variable, x)
...
...
@@ -176,7 +176,7 @@ class AssignSub(PrimitiveWithInfer):
>>> def __init__(self):
>>> super(Net, self).__init__()
>>> self.AssignSub = P.AssignSub()
>>> self.variable = Parameter(initializer(1, [1], mindspore.int64), name="global_step")
>>> self.variable =
mindspore.
Parameter(initializer(1, [1], mindspore.int64), name="global_step")
>>>
>>> def construct(self, x):
>>> self.AssignSub(self.variable, x)
...
...
mindspore/ops/operations/nn_ops.py
浏览文件 @
50ed76bc
...
...
@@ -154,7 +154,7 @@ class ReLU(PrimitiveWithInfer):
Tensor, with the same type and shape as the `input_x`.
Examples:
>>> input_x = Tensor(np.array([[-1.0, 4.0, -8.0], [2.0, -5.0, 9.0]]
, np.float32)
)
>>> input_x = Tensor(np.array([[-1.0, 4.0, -8.0], [2.0, -5.0, 9.0]]
), mindspore.float32
)
>>> relu = P.ReLU()
>>> result = relu(input_x)
[[0, 4.0, 0.0], [2.0, 0.0, 9.0]]
...
...
@@ -187,7 +187,7 @@ class ReLU6(PrimitiveWithInfer):
Tensor, with the same type and shape as the `input_x`.
Examples:
>>> input_x = Tensor(np.array([[-1.0, 4.0, -8.0], [2.0, -5.0, 9.0]]
, np.float32)
)
>>> input_x = Tensor(np.array([[-1.0, 4.0, -8.0], [2.0, -5.0, 9.0]]
), mindspore.float32
)
>>> relu6 = P.ReLU6()
>>> result = relu6(input_x)
"""
...
...
@@ -221,7 +221,7 @@ class Elu(PrimitiveWithInfer):
Tensor, has the same shape and data type as `input_x`.
Examples:
>>> input_x = Tensor(np.array([[-1.0, 4.0, -8.0], [2.0, -5.0, 9.0]]
, np.float32)
)
>>> input_x = Tensor(np.array([[-1.0, 4.0, -8.0], [2.0, -5.0, 9.0]]
), mindspore.float32
)
>>> elu = P.Elu()
>>> result = elu(input_x)
Tensor([[-0.632 4.0 -0.999]
...
...
mindspore/ops/operations/other_ops.py
浏览文件 @
50ed76bc
...
...
@@ -76,7 +76,7 @@ class BoundingBoxEncode(PrimitiveWithInfer):
Tensor, encoded bounding boxes.
Examples:
>>> boundingbox_encode = BoundingBoxEncode(means=(0.0, 0.0, 0.0, 0.0), stds=(1.0, 1.0, 1.0, 1.0))
>>> boundingbox_encode =
P.
BoundingBoxEncode(means=(0.0, 0.0, 0.0, 0.0), stds=(1.0, 1.0, 1.0, 1.0))
>>> delta_box = boundingbox_encode(anchor_box, groundtruth_box)
"""
...
...
@@ -119,7 +119,7 @@ class BoundingBoxDecode(PrimitiveWithInfer):
Tensor, decoded boxes.
Examples:
>>> boundingbox_decode = BoundingBoxDecode(means=(0.0, 0.0, 0.0, 0.0), stds=(1.0, 1.0, 1.0, 1.0),
>>> boundingbox_decode =
P.
BoundingBoxDecode(means=(0.0, 0.0, 0.0, 0.0), stds=(1.0, 1.0, 1.0, 1.0),
max_shape=(768, 1280), wh_ratio_clip=0.016)
>>> bbox = boundingbox_decode(anchor_box, deltas)
"""
...
...
@@ -208,7 +208,7 @@ class IOU(PrimitiveWithInfer):
KeyError: When `mode` is not 'iou' or 'iof'.
Examples:
>>> iou = IOU()
>>> iou =
P.
IOU()
>>> anchor_boxes = Tensor(np.random.randint(1,5, [10, 4]))
>>> gt_boxes = Tensor(np.random.randint(1,5, [3, 4]))
>>> iou(anchor_boxes, gt_boxes)
...
...
@@ -255,15 +255,15 @@ class MakeRefKey(Primitive):
>>> class Net(nn.Cell):
>>> def __init__(self):
>>> super(Net, self).__init__()
>>> self.y =
Parameter(Tensor(np.ones([6, 8, 10], np.int32)
), name="y")
>>> self.make_ref_key = MakeRefKey("y")
>>> self.y =
mindspore.Parameter(Tensor(np.ones([6, 8, 10]), mindspore.int32
), name="y")
>>> self.make_ref_key =
P.
MakeRefKey("y")
>>>
>>> def construct(self, x):
>>> key = self.make_ref_key()
>>> ref = F.make_ref(key, x, self.y)
>>> return ref * x
>>>
>>> x = Tensor(np.ones([3, 4, 5]
, np.int32)
)
>>> x = Tensor(np.ones([3, 4, 5]
), mindspore.int32
)
>>> net = Net()
>>> net(x)
"""
...
...
mindspore/ops/operations/random_ops.py
浏览文件 @
50ed76bc
...
...
@@ -44,7 +44,7 @@ class RandomChoiceWithMask(PrimitiveWithInfer):
- **mask** (Tensor) - The output has shape 1-D.
Examples:
>>> rnd_choice_mask = RandomChoiceWithMask()
>>> rnd_choice_mask =
P.
RandomChoiceWithMask()
>>> input_x = Tensor(np.ones(shape=[240000, 4]), mindspore.bool_)
>>> output_y, output_mask = rnd_choice_mask(input_x)
"""
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录