Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
7abe692f
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看板
提交
7abe692f
编写于
9月 08, 2020
作者:
L
lvchangquan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add set_grad() for pynative mode in model_zoo network
上级
d05c22a1
变更
17
显示空白变更内容
内联
并排
Showing
17 changed file
with
25 addition
and
0 deletion
+25
-0
model_zoo/official/cv/faster_rcnn/src/network_define.py
model_zoo/official/cv/faster_rcnn/src/network_define.py
+1
-0
model_zoo/official/cv/maskrcnn/src/network_define.py
model_zoo/official/cv/maskrcnn/src/network_define.py
+1
-0
model_zoo/official/cv/ssd/src/ssd.py
model_zoo/official/cv/ssd/src/ssd.py
+1
-0
model_zoo/official/cv/yolov3_darknet53/src/yolo.py
model_zoo/official/cv/yolov3_darknet53/src/yolo.py
+1
-0
model_zoo/official/cv/yolov3_darknet53_quant/src/yolo.py
model_zoo/official/cv/yolov3_darknet53_quant/src/yolo.py
+1
-0
model_zoo/official/cv/yolov3_resnet18/src/yolov3.py
model_zoo/official/cv/yolov3_resnet18/src/yolov3.py
+1
-0
model_zoo/official/gnn/gat/src/utils.py
model_zoo/official/gnn/gat/src/utils.py
+1
-0
model_zoo/official/gnn/gcn/src/metrics.py
model_zoo/official/gnn/gcn/src/metrics.py
+1
-0
model_zoo/official/nlp/bert/src/bert_for_finetune.py
model_zoo/official/nlp/bert/src/bert_for_finetune.py
+2
-0
model_zoo/official/nlp/bert/src/bert_for_pre_training.py
model_zoo/official/nlp/bert/src/bert_for_pre_training.py
+3
-0
model_zoo/official/nlp/bert_thor/src/bert_for_pre_training.py
...l_zoo/official/nlp/bert_thor/src/bert_for_pre_training.py
+2
-0
model_zoo/official/nlp/mass/src/transformer/transformer_for_train.py
...fficial/nlp/mass/src/transformer/transformer_for_train.py
+1
-0
model_zoo/official/nlp/tinybert/src/tinybert_for_gd_td.py
model_zoo/official/nlp/tinybert/src/tinybert_for_gd_td.py
+4
-0
model_zoo/official/nlp/transformer/src/transformer_for_train.py
...zoo/official/nlp/transformer/src/transformer_for_train.py
+2
-0
model_zoo/official/recommend/deepfm/src/deepfm.py
model_zoo/official/recommend/deepfm/src/deepfm.py
+1
-0
model_zoo/official/recommend/wide_and_deep/src/wide_and_deep.py
...zoo/official/recommend/wide_and_deep/src/wide_and_deep.py
+1
-0
model_zoo/official/recommend/wide_and_deep_multitable/src/wide_and_deep.py
...l/recommend/wide_and_deep_multitable/src/wide_and_deep.py
+1
-0
未找到文件。
model_zoo/official/cv/faster_rcnn/src/network_define.py
浏览文件 @
7abe692f
...
...
@@ -160,6 +160,7 @@ class TrainOneStepCell(nn.Cell):
def
__init__
(
self
,
network
,
network_backbone
,
optimizer
,
sens
=
1.0
,
reduce_flag
=
False
,
mean
=
True
,
degree
=
None
):
super
(
TrainOneStepCell
,
self
).
__init__
(
auto_prefix
=
False
)
self
.
network
=
network
self
.
network
.
set_grad
()
self
.
backbone
=
network_backbone
self
.
weights
=
ParameterTuple
(
network
.
trainable_params
())
self
.
optimizer
=
optimizer
...
...
model_zoo/official/cv/maskrcnn/src/network_define.py
浏览文件 @
7abe692f
...
...
@@ -168,6 +168,7 @@ class TrainOneStepCell(nn.Cell):
def
__init__
(
self
,
network
,
network_backbone
,
optimizer
,
sens
=
1.0
,
reduce_flag
=
False
,
mean
=
True
,
degree
=
None
):
super
(
TrainOneStepCell
,
self
).
__init__
(
auto_prefix
=
False
)
self
.
network
=
network
self
.
network
.
set_grad
()
self
.
backbone
=
network_backbone
self
.
weights
=
ParameterTuple
(
network
.
trainable_params
())
self
.
optimizer
=
optimizer
...
...
model_zoo/official/cv/ssd/src/ssd.py
浏览文件 @
7abe692f
...
...
@@ -382,6 +382,7 @@ class TrainingWrapper(nn.Cell):
def
__init__
(
self
,
network
,
optimizer
,
sens
=
1.0
):
super
(
TrainingWrapper
,
self
).
__init__
(
auto_prefix
=
False
)
self
.
network
=
network
self
.
network
.
set_grad
()
self
.
weights
=
ms
.
ParameterTuple
(
network
.
trainable_params
())
self
.
optimizer
=
optimizer
self
.
grad
=
C
.
GradOperation
(
get_by_list
=
True
,
sens_param
=
True
)
...
...
model_zoo/official/cv/yolov3_darknet53/src/yolo.py
浏览文件 @
7abe692f
...
...
@@ -411,6 +411,7 @@ class TrainingWrapper(nn.Cell):
def
__init__
(
self
,
network
,
optimizer
,
sens
=
1.0
):
super
(
TrainingWrapper
,
self
).
__init__
(
auto_prefix
=
False
)
self
.
network
=
network
self
.
network
.
set_grad
()
self
.
weights
=
optimizer
.
parameters
self
.
optimizer
=
optimizer
self
.
grad
=
C
.
GradOperation
(
get_by_list
=
True
,
sens_param
=
True
)
...
...
model_zoo/official/cv/yolov3_darknet53_quant/src/yolo.py
浏览文件 @
7abe692f
...
...
@@ -411,6 +411,7 @@ class TrainingWrapper(nn.Cell):
def
__init__
(
self
,
network
,
optimizer
,
sens
=
1.0
):
super
(
TrainingWrapper
,
self
).
__init__
(
auto_prefix
=
False
)
self
.
network
=
network
self
.
network
.
set_grad
()
self
.
weights
=
optimizer
.
parameters
self
.
optimizer
=
optimizer
self
.
grad
=
C
.
GradOperation
(
get_by_list
=
True
,
sens_param
=
True
)
...
...
model_zoo/official/cv/yolov3_resnet18/src/yolov3.py
浏览文件 @
7abe692f
...
...
@@ -646,6 +646,7 @@ class TrainingWrapper(nn.Cell):
def
__init__
(
self
,
network
,
optimizer
,
sens
=
1.0
):
super
(
TrainingWrapper
,
self
).
__init__
(
auto_prefix
=
False
)
self
.
network
=
network
self
.
network
.
set_grad
()
self
.
weights
=
ms
.
ParameterTuple
(
network
.
trainable_params
())
self
.
optimizer
=
optimizer
self
.
grad
=
C
.
GradOperation
(
get_by_list
=
True
,
sens_param
=
True
)
...
...
model_zoo/official/gnn/gat/src/utils.py
浏览文件 @
7abe692f
...
...
@@ -167,6 +167,7 @@ class TrainGAT(nn.Cell):
def
__init__
(
self
,
network
,
num_class
,
label
,
mask
,
learning_rate
,
l2_coeff
):
super
(
TrainGAT
,
self
).
__init__
(
auto_prefix
=
False
)
self
.
network
=
network
self
.
network
.
set_grad
()
loss_net
=
LossNetWrapper
(
network
,
num_class
,
label
,
mask
,
l2_coeff
)
optimizer
=
nn
.
Adam
(
loss_net
.
trainable_params
(),
learning_rate
=
learning_rate
)
...
...
model_zoo/official/gnn/gcn/src/metrics.py
浏览文件 @
7abe692f
...
...
@@ -147,6 +147,7 @@ class TrainOneStepCell(nn.Cell):
def
__init__
(
self
,
network
,
optimizer
,
sens
=
1.0
):
super
(
TrainOneStepCell
,
self
).
__init__
(
auto_prefix
=
False
)
self
.
network
=
network
self
.
network
.
set_grad
()
self
.
network
.
add_flags
(
defer_inline
=
True
)
self
.
weights
=
ParameterTuple
(
network
.
trainable_params
())
self
.
optimizer
=
optimizer
...
...
model_zoo/official/nlp/bert/src/bert_for_finetune.py
浏览文件 @
7abe692f
...
...
@@ -55,6 +55,7 @@ class BertFinetuneCell(nn.Cell):
super
(
BertFinetuneCell
,
self
).
__init__
(
auto_prefix
=
False
)
self
.
network
=
network
self
.
network
.
set_grad
()
self
.
weights
=
optimizer
.
parameters
self
.
optimizer
=
optimizer
self
.
grad
=
C
.
GradOperation
(
get_by_list
=
True
,
...
...
@@ -157,6 +158,7 @@ class BertSquadCell(nn.Cell):
def
__init__
(
self
,
network
,
optimizer
,
scale_update_cell
=
None
):
super
(
BertSquadCell
,
self
).
__init__
(
auto_prefix
=
False
)
self
.
network
=
network
self
.
network
.
set_grad
()
self
.
weights
=
optimizer
.
parameters
self
.
optimizer
=
optimizer
self
.
grad
=
C
.
GradOperation
(
get_by_list
=
True
,
sens_param
=
True
)
...
...
model_zoo/official/nlp/bert/src/bert_for_pre_training.py
浏览文件 @
7abe692f
...
...
@@ -273,6 +273,7 @@ class BertTrainOneStepCell(nn.Cell):
def
__init__
(
self
,
network
,
optimizer
,
sens
=
1.0
):
super
(
BertTrainOneStepCell
,
self
).
__init__
(
auto_prefix
=
False
)
self
.
network
=
network
self
.
network
.
set_grad
()
self
.
weights
=
optimizer
.
parameters
self
.
optimizer
=
optimizer
self
.
grad
=
C
.
GradOperation
(
get_by_list
=
True
,
sens_param
=
True
)
...
...
@@ -352,6 +353,7 @@ class BertTrainOneStepWithLossScaleCell(nn.Cell):
def
__init__
(
self
,
network
,
optimizer
,
scale_update_cell
=
None
,
enable_global_norm
=
False
):
super
(
BertTrainOneStepWithLossScaleCell
,
self
).
__init__
(
auto_prefix
=
False
)
self
.
network
=
network
self
.
network
.
set_grad
()
self
.
weights
=
optimizer
.
parameters
self
.
optimizer
=
optimizer
self
.
enable_global_norm
=
enable_global_norm
...
...
@@ -482,6 +484,7 @@ class BertTrainAccumulateStepsWithLossScaleCell(nn.Cell):
def
__init__
(
self
,
network
,
optimizer
,
scale_update_cell
=
None
,
accumulation_steps
=
1
,
enable_global_norm
=
False
):
super
(
BertTrainAccumulateStepsWithLossScaleCell
,
self
).
__init__
(
auto_prefix
=
False
)
self
.
network
=
network
self
.
network
.
set_grad
()
self
.
weights
=
optimizer
.
parameters
self
.
optimizer
=
optimizer
self
.
accumulation_steps
=
accumulation_steps
...
...
model_zoo/official/nlp/bert_thor/src/bert_for_pre_training.py
浏览文件 @
7abe692f
...
...
@@ -291,6 +291,7 @@ class BertTrainOneStepCell(nn.Cell):
def
__init__
(
self
,
network
,
optimizer
,
sens
=
1.0
):
super
(
BertTrainOneStepCell
,
self
).
__init__
(
auto_prefix
=
False
)
self
.
network
=
network
self
.
network
.
set_grad
()
self
.
weights
=
optimizer
.
parameters
self
.
optimizer
=
optimizer
self
.
grad
=
C
.
GradOperation
(
get_by_list
=
True
,
sens_param
=
True
)
...
...
@@ -371,6 +372,7 @@ class BertTrainOneStepWithLossScaleCell(nn.Cell):
def
__init__
(
self
,
network
,
optimizer
,
scale_update_cell
=
None
):
super
(
BertTrainOneStepWithLossScaleCell
,
self
).
__init__
(
auto_prefix
=
False
)
self
.
network
=
network
self
.
network
.
set_grad
()
self
.
weights
=
optimizer
.
parameters
self
.
optimizer
=
optimizer
self
.
grad
=
C
.
GradOperation
(
get_by_list
=
True
,
...
...
model_zoo/official/nlp/mass/src/transformer/transformer_for_train.py
浏览文件 @
7abe692f
...
...
@@ -236,6 +236,7 @@ class TransformerTrainOneStepWithLossScaleCell(nn.Cell):
super
(
TransformerTrainOneStepWithLossScaleCell
,
self
).
__init__
(
auto_prefix
=
False
)
self
.
network
=
network
self
.
network
.
set_grad
()
self
.
network
.
add_flags
(
defer_inline
=
True
)
self
.
weights
=
optimizer
.
parameters
self
.
optimizer
=
optimizer
...
...
model_zoo/official/nlp/tinybert/src/tinybert_for_gd_td.py
浏览文件 @
7abe692f
...
...
@@ -216,6 +216,7 @@ class BertTrainWithLossScaleCell(nn.Cell):
def
__init__
(
self
,
network
,
optimizer
,
scale_update_cell
=
None
):
super
(
BertTrainWithLossScaleCell
,
self
).
__init__
(
auto_prefix
=
False
)
self
.
network
=
network
self
.
network
.
set_grad
()
self
.
weights
=
optimizer
.
parameters
self
.
optimizer
=
optimizer
self
.
grad
=
C
.
GradOperation
(
get_by_list
=
True
,
...
...
@@ -306,6 +307,7 @@ class BertTrainCell(nn.Cell):
def
__init__
(
self
,
network
,
optimizer
,
sens
=
1.0
):
super
(
BertTrainCell
,
self
).
__init__
(
auto_prefix
=
False
)
self
.
network
=
network
self
.
network
.
set_grad
()
self
.
weights
=
optimizer
.
parameters
self
.
optimizer
=
optimizer
self
.
sens
=
sens
...
...
@@ -470,6 +472,7 @@ class BertEvaluationWithLossScaleCell(nn.Cell):
def
__init__
(
self
,
network
,
optimizer
,
scale_update_cell
=
None
):
super
(
BertEvaluationWithLossScaleCell
,
self
).
__init__
(
auto_prefix
=
False
)
self
.
network
=
network
self
.
network
.
set_grad
()
self
.
weights
=
optimizer
.
parameters
self
.
optimizer
=
optimizer
self
.
grad
=
C
.
GradOperation
(
get_by_list
=
True
,
...
...
@@ -556,6 +559,7 @@ class BertEvaluationCell(nn.Cell):
def
__init__
(
self
,
network
,
optimizer
,
sens
=
1.0
):
super
(
BertEvaluationCell
,
self
).
__init__
(
auto_prefix
=
False
)
self
.
network
=
network
self
.
network
.
set_grad
()
self
.
weights
=
optimizer
.
parameters
self
.
optimizer
=
optimizer
self
.
sens
=
sens
...
...
model_zoo/official/nlp/transformer/src/transformer_for_train.py
浏览文件 @
7abe692f
...
...
@@ -156,6 +156,7 @@ class TransformerTrainOneStepCell(nn.Cell):
def
__init__
(
self
,
network
,
optimizer
,
sens
=
1.0
):
super
(
TransformerTrainOneStepCell
,
self
).
__init__
(
auto_prefix
=
False
)
self
.
network
=
network
self
.
network
.
set_grad
()
self
.
weights
=
ParameterTuple
(
network
.
trainable_params
())
self
.
optimizer
=
optimizer
self
.
grad
=
C
.
GradOperation
(
get_by_list
=
True
,
sens_param
=
True
)
...
...
@@ -241,6 +242,7 @@ class TransformerTrainOneStepWithLossScaleCell(nn.Cell):
def
__init__
(
self
,
network
,
optimizer
,
scale_update_cell
=
None
):
super
(
TransformerTrainOneStepWithLossScaleCell
,
self
).
__init__
(
auto_prefix
=
False
)
self
.
network
=
network
self
.
network
.
set_grad
()
self
.
network
.
add_flags
(
defer_inline
=
True
)
self
.
weights
=
ParameterTuple
(
network
.
trainable_params
())
self
.
optimizer
=
optimizer
...
...
model_zoo/official/recommend/deepfm/src/deepfm.py
浏览文件 @
7abe692f
...
...
@@ -282,6 +282,7 @@ class TrainStepWrap(nn.Cell):
def
__init__
(
self
,
network
,
lr
=
5e-8
,
eps
=
1e-8
,
loss_scale
=
1000.0
):
super
(
TrainStepWrap
,
self
).
__init__
(
auto_prefix
=
False
)
self
.
network
=
network
self
.
network
.
set_grad
()
self
.
network
.
set_train
()
self
.
weights
=
ParameterTuple
(
network
.
trainable_params
())
self
.
optimizer
=
Adam
(
self
.
weights
,
learning_rate
=
lr
,
eps
=
eps
,
loss_scale
=
loss_scale
)
...
...
model_zoo/official/recommend/wide_and_deep/src/wide_and_deep.py
浏览文件 @
7abe692f
...
...
@@ -328,6 +328,7 @@ class TrainStepWrap(nn.Cell):
parallel_mode
=
context
.
get_auto_parallel_context
(
"parallel_mode"
)
is_auto_parallel
=
parallel_mode
in
(
ParallelMode
.
SEMI_AUTO_PARALLEL
,
ParallelMode
.
AUTO_PARALLEL
)
self
.
network
=
network
self
.
network
.
set_grad
()
self
.
network
.
set_train
()
self
.
trainable_params
=
network
.
trainable_params
()
weights_w
=
[]
...
...
model_zoo/official/recommend/wide_and_deep_multitable/src/wide_and_deep.py
浏览文件 @
7abe692f
...
...
@@ -510,6 +510,7 @@ class TrainStepWrap(nn.Cell):
def
__init__
(
self
,
network
,
config
,
sens
=
1000.0
):
super
(
TrainStepWrap
,
self
).
__init__
()
self
.
network
=
network
self
.
network
.
set_grad
()
self
.
network
.
set_train
()
self
.
trainable_params
=
network
.
trainable_params
()
weights_w
=
[]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录