Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
正统之独孤求败
mindspore
提交
236204f9
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,发现更多精彩内容 >>
提交
236204f9
编写于
8月 03, 2020
作者:
F
fangzehua
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix matrixdiag floordiv softmax
上级
51fcaf6e
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
9 addition
and
22 deletion
+9
-22
mindspore/nn/layer/basic.py
mindspore/nn/layer/basic.py
+3
-3
mindspore/nn/loss/loss.py
mindspore/nn/loss/loss.py
+2
-1
mindspore/ops/_grad/grad_math_ops.py
mindspore/ops/_grad/grad_math_ops.py
+2
-12
mindspore/ops/_grad/grad_nn_ops.py
mindspore/ops/_grad/grad_nn_ops.py
+2
-6
未找到文件。
mindspore/nn/layer/basic.py
浏览文件 @
236204f9
...
...
@@ -591,7 +591,7 @@ class MatrixDiagPart(Cell):
Tensor, same type as input `x`. The shape should be x.shape[:-2] + [min(x.shape[-2:])].
Examples:
>>> x = Tensor([[[-1, 0], [0, 1]], [-1, 0], [0, 1]], [[-1, 0], [0, 1]]], mindspore.float32)
>>> x = Tensor([[[-1, 0], [0, 1]], [
[
-1, 0], [0, 1]], [[-1, 0], [0, 1]]], mindspore.float32)
>>> matrix_diag_part = nn.MatrixDiagPart()
>>> result = matrix_diag_part(x)
[[-1., 1.], [-1., 1.], [-1., 1.]]
...
...
@@ -622,11 +622,11 @@ class MatrixSetDiag(Cell):
Tensor, same type as input `x`. The shape same as `x`.
Examples:
>>> x = Tensor([[[-1, 0], [0, 1]], [-1, 0], [0, 1]], [[-1, 0], [0, 1]]], mindspore.float32)
>>> x = Tensor([[[-1, 0], [0, 1]], [
[
-1, 0], [0, 1]], [[-1, 0], [0, 1]]], mindspore.float32)
>>> diagonal = Tensor([[-1., 2.], [-1., 1.], [-1., 1.]], mindspore.float32)
>>> matrix_set_diag = nn.MatrixSetDiag()
>>> result = matrix_set_diag(x, diagonal)
[[[-1, 0], [0, 2]], [-1, 0], [0, 1]], [[-1, 0], [0, 1]]]
[[[-1, 0], [0, 2]], [
[
-1, 0], [0, 1]], [[-1, 0], [0, 1]]]
"""
def
__init__
(
self
):
super
(
MatrixSetDiag
,
self
).
__init__
()
...
...
mindspore/nn/loss/loss.py
浏览文件 @
236204f9
...
...
@@ -218,7 +218,8 @@ class SoftmaxCrossEntropyWithLogits(_Loss):
sparse (bool): Specifies whether labels use sparse format or not. Default: False.
reduction (Union[str, None]): Type of reduction to apply to loss. Support 'sum' or 'mean' If None,
do not reduction. Default: None.
smooth_factor (float): Label smoothing factor. It is a optional input. Default: 0.
smooth_factor (float): Label smoothing factor. It is a optional input which should be in range [0, 1].
Default: 0.
num_classes (int): The number of classes in the task. It is a optional input Default: 2.
Inputs:
...
...
mindspore/ops/_grad/grad_math_ops.py
浏览文件 @
236204f9
...
...
@@ -284,14 +284,9 @@ def get_bprop_ceil(self):
@
bprop_getters
.
register
(
P
.
FloorDiv
)
def
get_bprop_floordiv
(
self
):
"""Grad definition for `FloorDiv` operation."""
div_op
=
P
.
FloorDiv
()
neg
=
P
.
Neg
()
mul_op
=
P
.
Mul
()
def
bprop
(
x
,
y
,
out
,
dout
):
bc_x
=
div_op
(
dout
,
y
)
bc_y
=
neg
(
mul_op
(
bc_x
,
out
))
return
binop_grad_common
(
x
,
y
,
bc_x
,
bc_y
)
return
zeros_like
(
x
),
zeros_like
(
y
)
return
bprop
...
...
@@ -311,14 +306,9 @@ def get_bprop_floormod(self):
@
bprop_getters
.
register
(
P
.
TruncateDiv
)
def
get_bprop_truncate_div
(
self
):
"""Grad definition for `TruncateDiv` operation."""
div_op
=
P
.
TruncateDiv
()
neg
=
P
.
Neg
()
mul_op
=
P
.
Mul
()
def
bprop
(
x
,
y
,
out
,
dout
):
bc_x
=
div_op
(
dout
,
y
)
bc_y
=
neg
(
mul_op
(
bc_x
,
out
))
return
binop_grad_common
(
x
,
y
,
bc_x
,
bc_y
)
return
zeros_like
(
x
),
zeros_like
(
y
)
return
bprop
...
...
mindspore/ops/_grad/grad_nn_ops.py
浏览文件 @
236204f9
...
...
@@ -14,7 +14,6 @@
# ============================================================================
"""Define the grad rules of neural network related operations."""
import
math
import
numpy
as
np
from
mindspore.ops
import
_selected_grad_ops
as
SG
from
mindspore.ops.primitive
import
constexpr
...
...
@@ -632,11 +631,8 @@ def get_bprop_onehot(self):
@
constexpr
def
_range_op
(
start
,
limit
,
delta
,
dtype
):
"""helper function for Grad TopK"""
range_op
=
inner
.
Range
(
float
(
start
),
float
(
limit
),
float
(
delta
))
length_input
=
math
.
ceil
((
limit
-
start
)
/
delta
)
input_tensor
=
Tensor
(
list
(
range
(
length_input
)),
dtype
)
range_out
=
range_op
(
input_tensor
)
return
range_out
output_tensor
=
Tensor
(
list
(
range
(
start
,
limit
,
delta
)),
dtype
)
return
output_tensor
@
constexpr
def
_get_1d_shape
(
in_shape
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录