Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
b958f15d
M
mindspore
项目概览
magicwindyyd
/
mindspore
与 Fork 源项目一致
Fork自
MindSpore / mindspore
通知
1
Star
1
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看板
提交
b958f15d
编写于
9月 09, 2020
作者:
L
lihongkang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix bugs
上级
0c316e52
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
28 addition
and
12 deletion
+28
-12
mindspore/nn/layer/basic.py
mindspore/nn/layer/basic.py
+9
-5
mindspore/nn/layer/normalization.py
mindspore/nn/layer/normalization.py
+11
-2
mindspore/ops/operations/array_ops.py
mindspore/ops/operations/array_ops.py
+2
-2
mindspore/ops/operations/math_ops.py
mindspore/ops/operations/math_ops.py
+3
-3
mindspore/ops/operations/other_ops.py
mindspore/ops/operations/other_ops.py
+3
-0
未找到文件。
mindspore/nn/layer/basic.py
浏览文件 @
b958f15d
...
...
@@ -65,18 +65,22 @@ class Dropout(Cell):
dtype (:class:`mindspore.dtype`): Data type of input. Default: mindspore.float32.
Raises:
ValueError: If `keep_prob` is not in range (0, 1
)
.
ValueError: If `keep_prob` is not in range (0, 1
]
.
Inputs:
- **input** (Tensor) -
An N-D T
ensor.
- **input** (Tensor) -
The input t
ensor.
Outputs:
Tensor, output tensor with the same shape as the input.
Examples:
>>> x = Tensor(np.ones([2
0, 16, 50
]), mindspore.float32)
>>> x = Tensor(np.ones([2
, 2, 3
]), mindspore.float32)
>>> net = nn.Dropout(keep_prob=0.8)
>>> net(x)
[[[1.0, 1.0, 1.0],
[1.0, 1.0, 1.0]],
[[1.0, 1.0, 1.0],
[1.0, 1.0, 1.0]]]
"""
def
__init__
(
self
,
keep_prob
=
0.5
,
seed0
=
0
,
seed1
=
0
,
dtype
=
mstype
.
float32
):
...
...
@@ -84,6 +88,7 @@ class Dropout(Cell):
if
keep_prob
<=
0
or
keep_prob
>
1
:
raise
ValueError
(
"dropout probability should be a number in range (0, 1], but got {}"
.
format
(
keep_prob
))
validator
.
check_subclass
(
"dtype"
,
dtype
,
mstype
.
number_type
,
self
.
cls_name
)
validator
.
check_value_type
(
'keep_prob'
,
keep_prob
,
[
float
],
self
.
cls_name
)
self
.
keep_prob
=
keep_prob
self
.
seed0
=
seed0
self
.
seed1
=
seed1
...
...
@@ -107,8 +112,7 @@ class Dropout(Cell):
return
x
shape
=
self
.
get_shape
(
x
)
dtype
=
P
.
DType
()(
x
)
keep_prob
=
self
.
cast
(
self
.
keep_prob
,
dtype
)
keep_prob
=
self
.
cast
(
self
.
keep_prob
,
mstype
.
float32
)
output
=
self
.
dropout_gen_mask
(
shape
,
keep_prob
)
return
self
.
dropout_do_mask
(
x
,
output
,
keep_prob
)
...
...
mindspore/nn/layer/normalization.py
浏览文件 @
b958f15d
...
...
@@ -585,9 +585,18 @@ class GroupNorm(Cell):
Tensor, the normalized and scaled offset tensor, has the same shape and data type as the `input_x`.
Examples:
>>> goup_norm_op = nn.GroupNorm(
16, 64
)
>>> x = Tensor(np.ones([1,
64, 256, 256
], np.float32))
>>> goup_norm_op = nn.GroupNorm(
2, 2
)
>>> x = Tensor(np.ones([1,
2, 4, 4
], np.float32))
>>> goup_norm_op(x)
[[[[0. 0. 0. 0.]
[0. 0. 0. 0.]
[0. 0. 0. 0.]
[0. 0. 0. 0.]]
[[0. 0. 0. 0.]
[0. 0. 0. 0.]
[0. 0. 0. 0.]
[0. 0. 0. 0.]]]]
"""
def
__init__
(
self
,
num_groups
,
num_channels
,
eps
=
1e-05
,
affine
=
True
,
gamma_init
=
'ones'
,
beta_init
=
'zeros'
):
...
...
mindspore/ops/operations/array_ops.py
浏览文件 @
b958f15d
...
...
@@ -1360,7 +1360,7 @@ class Tile(PrimitiveWithInfer):
- **multiples** (tuple[int]) - The input tuple is constructed by multiple
integers, i.e., :math:`(y_1, y_2, ..., y_S)`. The length of `multiples`
can't be smaller than the length of shape in `input_x`.
can't be smaller than the length of shape in `input_x`.
Only constant value is allowed.
Outputs:
Tensor, has the same type as the `input_x`.
...
...
@@ -1400,7 +1400,7 @@ class Tile(PrimitiveWithInfer):
def
__infer__
(
self
,
x
,
multiples
):
multiples_v
=
multiples
[
'value'
]
x_shp
=
x
[
'shape'
]
validator
.
check_value_type
(
"
shape
"
,
multiples_v
,
[
tuple
],
self
.
name
)
validator
.
check_value_type
(
"
multiples
"
,
multiples_v
,
[
tuple
],
self
.
name
)
for
i
,
multiple
in
enumerate
(
multiples_v
):
validator
.
check_value_type
(
"multiples[%d]"
%
i
,
multiple
,
[
int
],
self
.
name
)
validator
.
check_value_type
(
"x[
\'
dtype
\'
]"
,
x
[
"dtype"
],
mstype
.
tensor_type
,
self
.
name
)
...
...
mindspore/ops/operations/math_ops.py
浏览文件 @
b958f15d
...
...
@@ -1382,10 +1382,10 @@ class Exp(PrimitiveWithInfer):
Returns exponential of a tensor element-wise.
Inputs:
- **input_x** (Tensor) - The input tensor.
- **input_x** (Tensor) - The input tensor.
The data type mast be float16 or float32.
Outputs:
Tensor, has the same shape as the `input_x`.
Tensor, has the same shape a
nd dtype a
s the `input_x`.
Examples:
>>> input_x = Tensor(np.array([1.0, 2.0, 4.0]), mindspore.float32)
...
...
@@ -1452,7 +1452,7 @@ class HistogramFixedWidth(PrimitiveWithInfer):
width and determined by the arguments range and nbins.
Args:
dtype (str
ing
): An optional attribute. Must be one of the following types: "int32", "int64". Default: "int32".
dtype (str): An optional attribute. Must be one of the following types: "int32", "int64". Default: "int32".
nbins (int): The number of histogram bins, the type is a positive integer.
Inputs:
...
...
mindspore/ops/operations/other_ops.py
浏览文件 @
b958f15d
...
...
@@ -264,6 +264,9 @@ class IOU(PrimitiveWithInfer):
>>> anchor_boxes = Tensor(np.random.randint(1.0, 5.0, [3, 4]), mindspore.float16)
>>> gt_boxes = Tensor(np.random.randint(1.0, 5.0, [3, 4]), mindspore.float16)
>>> iou(anchor_boxes, gt_boxes)
[[0.0, 65504, 65504],
[0.0, 0.0, 0.0],
[0.22253, 0.0, 0.0]]
"""
@
prim_attr_register
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录