Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
兔爷不爱我
mindspore
提交
8705545b
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 搜索 >>
提交
8705545b
编写于
7月 18, 2020
作者:
L
liuxiao93
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix bug about output of AddNGrad.
上级
32921ea3
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
15 addition
and
8 deletion
+15
-8
mindspore/nn/layer/normalization.py
mindspore/nn/layer/normalization.py
+8
-0
mindspore/ops/_grad/grad_math_ops.py
mindspore/ops/_grad/grad_math_ops.py
+3
-2
tests/ut/python/ops/test_ops.py
tests/ut/python/ops/test_ops.py
+2
-4
tests/ut/python/pynative_mode/nn/test_batchnorm.py
tests/ut/python/pynative_mode/nn/test_batchnorm.py
+2
-2
未找到文件。
mindspore/nn/layer/normalization.py
浏览文件 @
8705545b
...
...
@@ -149,6 +149,8 @@ class _BatchNorm(Cell):
def
construct
(
self
,
x
):
if
self
.
input_dims
==
'2d'
:
_shape_check
(
self
.
shape
(
x
))
if
self
.
input_dims
==
'1d'
:
_shape_check_2d
(
self
.
shape
(
x
))
if
self
.
use_batch_statistics
is
None
:
flag
=
self
.
training
else
:
...
...
@@ -200,6 +202,12 @@ def _channel_check(channel, num_channel):
raise
ValueError
(
"the input channel is not equal with num_channel"
)
@
constexpr
def
_shape_check_2d
(
input_shape
):
if
len
(
input_shape
)
!=
2
:
raise
ValueError
(
"The input must has 2 dims."
)
@
constexpr
def
_shape_check
(
in_shape
):
if
len
(
in_shape
)
!=
4
:
...
...
mindspore/ops/_grad/grad_math_ops.py
浏览文件 @
8705545b
...
...
@@ -980,7 +980,8 @@ def get_bprop_scalar_accumulatenv2(self):
dx
=
()
for
_
in
range
(
len
(
x
)):
dx
=
dx
+
(
dout
,)
return
dx
return
(
dx
,)
return
bprop
...
...
@@ -992,7 +993,7 @@ def get_bprop_scalar_addn(self):
dx
=
()
for
_
in
range
(
len
(
x
)):
dx
=
dx
+
(
dout
,)
return
dx
return
(
dx
,)
return
bprop
...
...
tests/ut/python/ops/test_ops.py
浏览文件 @
8705545b
...
...
@@ -1671,13 +1671,11 @@ test_case_array_ops = [
(
'AddN'
,
{
'block'
:
NetForTupleInput
(
P
.
AddN
()),
'desc_inputs'
:
[[
2
,
3
,
3
,
5
],
[
2
,
3
,
3
,
5
]],
'desc_bprop'
:
[[
2
,
3
,
3
,
5
]],
'skip'
:
[
'backward'
]}),
'desc_bprop'
:
[[
2
,
3
,
3
,
5
]]}),
(
'AccumulateNV2'
,
{
'block'
:
NetForTupleInput
(
P
.
AccumulateNV2
()),
'desc_inputs'
:
[[
2
,
3
,
3
,
5
],
[
2
,
3
,
3
,
5
]],
'desc_bprop'
:
[[
2
,
3
,
3
,
5
]],
'skip'
:
[
'backward'
]}),
'desc_bprop'
:
[[
2
,
3
,
3
,
5
]]}),
(
'Shape'
,
{
'block'
:
P
.
Shape
(),
'desc_inputs'
:
[[
3
,
3
,
2
,
2
]],
...
...
tests/ut/python/pynative_mode/nn/test_batchnorm.py
浏览文件 @
8705545b
...
...
@@ -67,10 +67,10 @@ def test_bn2d():
def
test_bn1d
():
"""ut of nn.BatchNorm1d"""
bn
=
nn
.
BatchNorm1d
(
3
)
input_data
=
Tensor
(
np
.
random
.
randint
(
0
,
1
,
[
1
,
3
,
100
,
100
]).
astype
(
np
.
float32
))
input_data
=
Tensor
(
np
.
random
.
randint
(
0
,
1
,
[
1
,
3
]).
astype
(
np
.
float32
))
output
=
bn
(
input_data
)
output_np
=
output
.
asnumpy
()
assert
isinstance
(
output_np
[
0
][
0
]
[
0
][
0
]
,
(
np
.
float32
,
np
.
float64
))
assert
isinstance
(
output_np
[
0
][
0
],
(
np
.
float32
,
np
.
float64
))
def
test_bn2d_train
():
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录