Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MindSpore
docs
提交
2cebcf25
D
docs
项目概览
MindSpore
/
docs
通知
4
Star
2
Fork
2
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2cebcf25
编写于
5月 18, 2020
作者:
J
jinyaohui
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove some context params
上级
5b316eb7
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
4 addition
and
14 deletion
+4
-14
tutorials/source_en/quick_start/quick_start.md
tutorials/source_en/quick_start/quick_start.md
+1
-2
tutorials/source_zh_cn/advanced_use/distributed_training.md
tutorials/source_zh_cn/advanced_use/distributed_training.md
+1
-2
tutorials/source_zh_cn/quick_start/quick_start.md
tutorials/source_zh_cn/quick_start/quick_start.md
+1
-2
tutorials/tutorial_code/distributed_training/resnet50_distributed_training.py
...ode/distributed_training/resnet50_distributed_training.py
+0
-2
tutorials/tutorial_code/lenet.py
tutorials/tutorial_code/lenet.py
+1
-2
tutorials/tutorial_code/resnet/cifar_resnet50.py
tutorials/tutorial_code/resnet/cifar_resnet50.py
+0
-2
tutorials/tutorial_code/sample_for_cloud/resnet50_train.py
tutorials/tutorial_code/sample_for_cloud/resnet50_train.py
+0
-2
未找到文件。
tutorials/source_en/quick_start/quick_start.md
浏览文件 @
2cebcf25
...
...
@@ -99,8 +99,7 @@ if __name__ == "__main__":
parser
.
add_argument
(
'--device_target'
,
type
=
str
,
default
=
"CPU"
,
choices
=
[
'Ascend'
,
'GPU'
,
'CPU'
],
help
=
'device where the code will be implemented (default: CPU)'
)
args
=
parser
.
parse_args
()
context
.
set_context
(
mode
=
context
.
GRAPH_MODE
,
device_target
=
args
.
device_target
,
enable_mem_reuse
=
False
)
context
.
set_context
(
mode
=
context
.
GRAPH_MODE
,
device_target
=
args
.
device_target
)
...
```
...
...
tutorials/source_zh_cn/advanced_use/distributed_training.md
浏览文件 @
2cebcf25
...
...
@@ -250,7 +250,6 @@ from resnet import resnet50
device_id
=
int
(
os
.
getenv
(
'DEVICE_ID'
))
context
.
set_context
(
mode
=
context
.
GRAPH_MODE
,
device_target
=
"Ascend"
)
context
.
set_context
(
device_id
=
device_id
)
# set device_id
context
.
set_context
(
enable_loop_sink
=
True
)
def
test_train_cifar
(
num_classes
=
10
,
epoch_size
=
10
):
context
.
set_auto_parallel_context
(
parallel_mode
=
ParallelMode
.
AUTO_PARALLEL
,
mirror_mean
=
True
)
...
...
@@ -263,7 +262,7 @@ def test_train_cifar(num_classes=10, epoch_size=10):
model
.
train
(
epoch_size
,
dataset
,
callbacks
=
[
loss_cb
],
dataset_sink_mode
=
True
)
```
其中,
-
`dataset_sink_mode=True`
,
`enable_loop_sink=True`
:表示采用数据集的下沉模式,即训练的计算下沉到硬件平台中执行。
-
`dataset_sink_mode=True`
:表示采用数据集的下沉模式,即训练的计算下沉到硬件平台中执行。
-
`LossMonitor`
:能够通过回调函数返回Loss值,用于监控损失函数。
## 运行脚本
...
...
tutorials/source_zh_cn/quick_start/quick_start.md
浏览文件 @
2cebcf25
...
...
@@ -101,8 +101,7 @@ if __name__ == "__main__":
parser
.
add_argument
(
'--device_target'
,
type
=
str
,
default
=
"CPU"
,
choices
=
[
'Ascend'
,
'GPU'
,
'CPU'
],
help
=
'device where the code will be implemented (default: CPU)'
)
args
=
parser
.
parse_args
()
context
.
set_context
(
mode
=
context
.
GRAPH_MODE
,
device_target
=
args
.
device_target
,
enable_mem_reuse
=
False
)
context
.
set_context
(
mode
=
context
.
GRAPH_MODE
,
device_target
=
args
.
device_target
)
...
```
...
...
tutorials/tutorial_code/distributed_training/resnet50_distributed_training.py
浏览文件 @
2cebcf25
...
...
@@ -36,8 +36,6 @@ from resnet import resnet50
device_id
=
int
(
os
.
getenv
(
'DEVICE_ID'
))
context
.
set_context
(
mode
=
context
.
GRAPH_MODE
,
device_target
=
"Ascend"
)
context
.
set_context
(
device_id
=
device_id
)
# set device_id
context
.
set_context
(
enable_loop_sink
=
True
)
context
.
set_context
(
enable_mem_reuse
=
False
)
init
()
rank_id
=
get_rank
()
...
...
tutorials/tutorial_code/lenet.py
浏览文件 @
2cebcf25
...
...
@@ -195,8 +195,7 @@ if __name__ == "__main__":
parser
.
add_argument
(
'--device_target'
,
type
=
str
,
default
=
"CPU"
,
choices
=
[
'Ascend'
,
'GPU'
,
'CPU'
],
help
=
'device where the code will be implemented (default: CPU)'
)
args
=
parser
.
parse_args
()
context
.
set_context
(
mode
=
context
.
GRAPH_MODE
,
device_target
=
args
.
device_target
,
enable_mem_reuse
=
False
)
context
.
set_context
(
mode
=
context
.
GRAPH_MODE
,
device_target
=
args
.
device_target
)
# download mnist dataset
download_dataset
()
# learning rate setting
...
...
tutorials/tutorial_code/resnet/cifar_resnet50.py
浏览文件 @
2cebcf25
...
...
@@ -55,8 +55,6 @@ data_home = args_opt.dataset_path
context
.
set_context
(
mode
=
context
.
GRAPH_MODE
,
device_target
=
"Ascend"
)
context
.
set_context
(
device_id
=
device_id
)
context
.
set_context
(
enable_loop_sink
=
False
)
context
.
set_context
(
enable_mem_reuse
=
False
)
def
create_dataset
(
repeat_num
=
1
,
training
=
True
):
"""
...
...
tutorials/tutorial_code/sample_for_cloud/resnet50_train.py
浏览文件 @
2cebcf25
...
...
@@ -117,8 +117,6 @@ def resnet50_train(args_opt):
# set graph mode and parallel mode
context
.
set_context
(
mode
=
context
.
GRAPH_MODE
,
device_target
=
"Ascend"
,
save_graphs
=
False
)
context
.
set_context
(
device_id
=
device_id
)
context
.
set_context
(
enable_loop_sink
=
True
)
context
.
set_context
(
enable_mem_reuse
=
True
)
if
device_num
>
1
:
context
.
set_auto_parallel_context
(
device_num
=
device_num
,
parallel_mode
=
ParallelMode
.
DATA_PARALLEL
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录