Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MindSpore
docs
提交
8a229d2c
D
docs
项目概览
MindSpore
/
docs
通知
5
Star
3
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看板
提交
8a229d2c
编写于
6月 05, 2020
作者:
M
mindspore-ci-bot
提交者:
Gitee
6月 05, 2020
浏览文件
操作
浏览文件
下载
差异文件
!213 add sink_mode=True for GPU&D
Merge pull request !213 from wukesong/modify_lenet_alexnet
上级
d01d82ea
7fd20bd9
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
12 addition
and
9 deletion
+12
-9
tutorials/source_en/quick_start/quick_start.md
tutorials/source_en/quick_start/quick_start.md
+4
-3
tutorials/source_zh_cn/quick_start/quick_start.md
tutorials/source_zh_cn/quick_start/quick_start.md
+4
-3
tutorials/tutorial_code/lenet.py
tutorials/tutorial_code/lenet.py
+4
-3
未找到文件。
tutorials/source_en/quick_start/quick_start.md
浏览文件 @
8a229d2c
...
...
@@ -103,6 +103,7 @@ if __name__ == "__main__":
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
)
dataset_sink_mode
=
not
args
.
device_target
==
"CPU"
...
```
...
...
@@ -341,12 +342,12 @@ from mindspore.train.callback import LossMonitor
from
mindspore.train
import
Model
...
def
train_net
(
args
,
model
,
epoch_size
,
mnist_path
,
repeat_size
,
ckpoint_cb
):
def
train_net
(
args
,
model
,
epoch_size
,
mnist_path
,
repeat_size
,
ckpoint_cb
,
sink_mode
):
"""define the training method"""
print
(
"============== Starting Training =============="
)
#load training dataset
ds_train
=
create_dataset
(
os
.
path
.
join
(
mnist_path
,
"train"
),
32
,
repeat_size
)
model
.
train
(
epoch_size
,
ds_train
,
callbacks
=
[
ckpoint_cb
,
LossMonitor
()],
dataset_sink_mode
=
Fals
e
)
# train
model
.
train
(
epoch_size
,
ds_train
,
callbacks
=
[
ckpoint_cb
,
LossMonitor
()],
dataset_sink_mode
=
sink_mod
e
)
# train
...
if
__name__
==
"__main__"
:
...
...
@@ -356,7 +357,7 @@ if __name__ == "__main__":
mnist_path
=
"./MNIST_Data"
repeat_size
=
epoch_size
model
=
Model
(
network
,
net_loss
,
net_opt
,
metrics
=
{
"Accuracy"
:
Accuracy
()})
train_net
(
args
,
model
,
epoch_size
,
mnist_path
,
repeat_size
,
ckpoint_cb
)
train_net
(
args
,
model
,
epoch_size
,
mnist_path
,
repeat_size
,
ckpoint_cb
,
dataset_sink_mode
)
...
```
In the preceding information:
...
...
tutorials/source_zh_cn/quick_start/quick_start.md
浏览文件 @
8a229d2c
...
...
@@ -104,6 +104,7 @@ if __name__ == "__main__":
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
)
dataset_sink_mode
=
not
args
.
device_target
==
"CPU"
...
```
...
...
@@ -341,12 +342,12 @@ from mindspore.train.callback import LossMonitor
from
mindspore.train
import
Model
...
def
train_net
(
args
,
model
,
epoch_size
,
mnist_path
,
repeat_size
,
ckpoint_cb
):
def
train_net
(
args
,
model
,
epoch_size
,
mnist_path
,
repeat_size
,
ckpoint_cb
,
sink_mode
):
"""define the training method"""
print
(
"============== Starting Training =============="
)
#load training dataset
ds_train
=
create_dataset
(
os
.
path
.
join
(
mnist_path
,
"train"
),
32
,
repeat_size
)
model
.
train
(
epoch_size
,
ds_train
,
callbacks
=
[
ckpoint_cb
,
LossMonitor
()],
dataset_sink_mode
=
Fals
e
)
model
.
train
(
epoch_size
,
ds_train
,
callbacks
=
[
ckpoint_cb
,
LossMonitor
()],
dataset_sink_mode
=
sink_mod
e
)
...
if
__name__
==
"__main__"
:
...
...
@@ -356,7 +357,7 @@ if __name__ == "__main__":
mnist_path
=
"./MNIST_Data"
repeat_size
=
epoch_size
model
=
Model
(
network
,
net_loss
,
net_opt
,
metrics
=
{
"Accuracy"
:
Accuracy
()})
train_net
(
args
,
model
,
epoch_size
,
mnist_path
,
repeat_size
,
ckpoint_cb
)
train_net
(
args
,
model
,
epoch_size
,
mnist_path
,
repeat_size
,
ckpoint_cb
,
dataset_sink_mode
)
...
```
其中,
...
...
tutorials/tutorial_code/lenet.py
浏览文件 @
8a229d2c
...
...
@@ -169,12 +169,12 @@ class LeNet5(nn.Cell):
return
x
def
train_net
(
args
,
model
,
epoch_size
,
mnist_path
,
repeat_size
,
ckpoint_cb
):
def
train_net
(
args
,
model
,
epoch_size
,
mnist_path
,
repeat_size
,
ckpoint_cb
,
sink_mode
):
"""Define the training method."""
print
(
"============== Starting Training =============="
)
# load training dataset
ds_train
=
create_dataset
(
os
.
path
.
join
(
mnist_path
,
"train"
),
32
,
repeat_size
)
model
.
train
(
epoch_size
,
ds_train
,
callbacks
=
[
ckpoint_cb
,
LossMonitor
()],
dataset_sink_mode
=
Fals
e
)
model
.
train
(
epoch_size
,
ds_train
,
callbacks
=
[
ckpoint_cb
,
LossMonitor
()],
dataset_sink_mode
=
sink_mod
e
)
def
test_net
(
args
,
network
,
model
,
mnist_path
):
...
...
@@ -196,6 +196,7 @@ if __name__ == "__main__":
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
)
dataset_sink_mode
=
not
args
.
device_target
==
"CPU"
# download mnist dataset
download_dataset
()
# learning rate setting
...
...
@@ -216,5 +217,5 @@ if __name__ == "__main__":
# group layers into an object with training and evaluation features
model
=
Model
(
network
,
net_loss
,
net_opt
,
metrics
=
{
"Accuracy"
:
Accuracy
()})
train_net
(
args
,
model
,
epoch_size
,
mnist_path
,
repeat_size
,
ckpoint_cb
)
train_net
(
args
,
model
,
epoch_size
,
mnist_path
,
repeat_size
,
ckpoint_cb
,
dataset_sink_mode
)
test_net
(
args
,
network
,
model
,
mnist_path
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录