Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
f9f0d30e
M
models
项目概览
PaddlePaddle
/
models
大约 1 年 前同步成功
通知
222
Star
6828
Fork
2962
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
602
列表
看板
标记
里程碑
合并请求
255
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
models
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
602
Issue
602
列表
看板
标记
里程碑
合并请求
255
合并请求
255
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
f9f0d30e
编写于
9月 01, 2020
作者:
A
arlesniak
提交者:
GitHub
9月 01, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Enable CPU training for DyGraph MNIST Resnet (#4824)
上级
64cde5d1
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
33 addition
and
6 deletion
+33
-6
dygraph/mnist/train.py
dygraph/mnist/train.py
+20
-4
dygraph/resnet/train.py
dygraph/resnet/train.py
+13
-2
未找到文件。
dygraph/mnist/train.py
浏览文件 @
f9f0d30e
...
@@ -35,6 +35,12 @@ def parse_args():
...
@@ -35,6 +35,12 @@ def parse_args():
)
)
parser
.
add_argument
(
"-e"
,
"--epoch"
,
default
=
5
,
type
=
int
,
help
=
"set epoch"
)
parser
.
add_argument
(
"-e"
,
"--epoch"
,
default
=
5
,
type
=
int
,
help
=
"set epoch"
)
parser
.
add_argument
(
"--ce"
,
action
=
"store_true"
,
help
=
"run ce"
)
parser
.
add_argument
(
"--ce"
,
action
=
"store_true"
,
help
=
"run ce"
)
parser
.
add_argument
(
'--use_gpu'
,
type
=
ast
.
literal_eval
,
default
=
True
,
help
=
'default use gpu.'
)
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
return
args
return
args
...
@@ -149,8 +155,13 @@ def test_mnist(reader, model, batch_size):
...
@@ -149,8 +155,13 @@ def test_mnist(reader, model, batch_size):
def
inference_mnist
():
def
inference_mnist
():
place
=
fluid
.
CUDAPlace
(
fluid
.
dygraph
.
parallel
.
Env
().
dev_id
)
\
if
not
args
.
use_gpu
:
if
args
.
use_data_parallel
else
fluid
.
CUDAPlace
(
0
)
place
=
fluid
.
CPUPlace
()
elif
not
args
.
use_data_parallel
:
place
=
fluid
.
CUDAPlace
(
0
)
else
:
place
=
fluid
.
CUDAPlace
(
fluid
.
dygraph
.
parallel
.
Env
().
dev_id
)
with
fluid
.
dygraph
.
guard
(
place
):
with
fluid
.
dygraph
.
guard
(
place
):
mnist_infer
=
MNIST
()
mnist_infer
=
MNIST
()
# load checkpoint
# load checkpoint
...
@@ -180,8 +191,13 @@ def train_mnist(args):
...
@@ -180,8 +191,13 @@ def train_mnist(args):
epoch_num
=
args
.
epoch
epoch_num
=
args
.
epoch
BATCH_SIZE
=
64
BATCH_SIZE
=
64
place
=
fluid
.
CUDAPlace
(
fluid
.
dygraph
.
parallel
.
Env
().
dev_id
)
\
if
not
args
.
use_gpu
:
if
args
.
use_data_parallel
else
fluid
.
CUDAPlace
(
0
)
place
=
fluid
.
CPUPlace
()
elif
not
args
.
use_data_parallel
:
place
=
fluid
.
CUDAPlace
(
0
)
else
:
place
=
fluid
.
CUDAPlace
(
fluid
.
dygraph
.
parallel
.
Env
().
dev_id
)
with
fluid
.
dygraph
.
guard
(
place
):
with
fluid
.
dygraph
.
guard
(
place
):
if
args
.
ce
:
if
args
.
ce
:
print
(
"ce mode"
)
print
(
"ce mode"
)
...
...
dygraph/resnet/train.py
浏览文件 @
f9f0d30e
...
@@ -130,6 +130,11 @@ def parse_args():
...
@@ -130,6 +130,11 @@ def parse_args():
type
=
float
,
type
=
float
,
default
=
[
0.229
,
0.224
,
0.225
],
default
=
[
0.229
,
0.224
,
0.225
],
help
=
"The std of input image data"
)
help
=
"The std of input image data"
)
parser
.
add_argument
(
'--use_gpu'
,
type
=
ast
.
literal_eval
,
default
=
True
,
help
=
'default use gpu.'
)
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
return
args
return
args
...
@@ -354,8 +359,14 @@ def eval(model, data):
...
@@ -354,8 +359,14 @@ def eval(model, data):
def
train_resnet
():
def
train_resnet
():
epoch
=
args
.
epoch
epoch
=
args
.
epoch
place
=
fluid
.
CUDAPlace
(
fluid
.
dygraph
.
parallel
.
Env
().
dev_id
)
\
if
args
.
use_data_parallel
else
fluid
.
CUDAPlace
(
0
)
if
not
args
.
use_gpu
:
place
=
fluid
.
CPUPlace
()
elif
not
args
.
use_data_parallel
:
place
=
fluid
.
CUDAPlace
(
0
)
else
:
place
=
fluid
.
CUDAPlace
(
fluid
.
dygraph
.
parallel
.
Env
().
dev_id
)
with
fluid
.
dygraph
.
guard
(
place
):
with
fluid
.
dygraph
.
guard
(
place
):
if
args
.
ce
:
if
args
.
ce
:
print
(
"ce mode"
)
print
(
"ce mode"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录