Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
c8545d66
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c8545d66
编写于
11月 27, 2019
作者:
H
hysunflower
提交者:
Jinhua Liang
11月 27, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add profiler for paddle gan (#3996)
* add_for_stgan_models * add_for_pix2pix_models * add_for_stargan_models
上级
0f9ad827
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
38 addition
and
2 deletion
+38
-2
PaddleCV/PaddleGAN/train.py
PaddleCV/PaddleGAN/train.py
+1
-1
PaddleCV/PaddleGAN/trainer/Pix2pix.py
PaddleCV/PaddleGAN/trainer/Pix2pix.py
+11
-0
PaddleCV/PaddleGAN/trainer/STGAN.py
PaddleCV/PaddleGAN/trainer/STGAN.py
+11
-0
PaddleCV/PaddleGAN/trainer/StarGAN.py
PaddleCV/PaddleGAN/trainer/StarGAN.py
+10
-1
PaddleCV/PaddleGAN/util/config.py
PaddleCV/PaddleGAN/util/config.py
+5
-0
未找到文件。
PaddleCV/PaddleGAN/train.py
浏览文件 @
c8545d66
...
...
@@ -70,7 +70,7 @@ if __name__ == "__main__":
if
cfg
.
profile
:
if
cfg
.
use_gpu
:
with
fluid
.
profiler
.
profiler
(
'All'
,
'total'
,
'/tmp/profile'
)
as
prof
:
cfg
.
profiler_path
)
as
prof
:
train
(
cfg
)
else
:
with
fluid
.
profiler
.
profiler
(
"CPU"
,
sorted_key
=
'total'
)
as
cpuprof
:
...
...
PaddleCV/PaddleGAN/trainer/Pix2pix.py
浏览文件 @
c8545d66
...
...
@@ -18,6 +18,7 @@ from __future__ import print_function
from
network.Pix2pix_network
import
Pix2pix_model
from
util
import
utility
import
paddle.fluid
as
fluid
from
paddle.fluid
import
profiler
import
sys
import
time
...
...
@@ -255,9 +256,13 @@ class Pix2pix(object):
t_time
=
0
total_train_batch
=
0
# used for benchmark
for
epoch_id
in
range
(
self
.
cfg
.
epoch
):
batch_id
=
0
for
tensor
in
loader
():
if
self
.
cfg
.
max_iter
and
total_train_batch
==
self
.
cfg
.
max_iter
:
# used for benchmark
return
s_time
=
time
.
time
()
tensor_A
,
tensor_B
=
tensor
[
0
][
'input_A'
],
tensor
[
0
][
'input_B'
]
...
...
@@ -294,6 +299,12 @@ class Pix2pix(object):
sys
.
stdout
.
flush
()
batch_id
+=
1
total_train_batch
+=
1
# used for benchmark
# profiler tools
if
self
.
cfg
.
profile
and
epoch_id
==
0
and
batch_id
==
self
.
cfg
.
print_freq
:
profiler
.
reset_profiler
()
elif
self
.
cfg
.
profile
and
epoch_id
==
0
and
batch_id
==
self
.
cfg
.
print_freq
+
5
:
return
if
self
.
cfg
.
run_test
:
image_name
=
fluid
.
data
(
...
...
PaddleCV/PaddleGAN/trainer/STGAN.py
浏览文件 @
c8545d66
...
...
@@ -17,6 +17,7 @@ from __future__ import print_function
from
network.STGAN_network
import
STGAN_model
from
util
import
utility
import
paddle.fluid
as
fluid
from
paddle.fluid
import
profiler
import
sys
import
time
import
copy
...
...
@@ -341,9 +342,13 @@ class STGAN(object):
t_time
=
0
total_train_batch
=
0
# used for benchmark
for
epoch_id
in
range
(
self
.
cfg
.
epoch
):
batch_id
=
0
for
data
in
py_reader
():
if
self
.
cfg
.
max_iter
and
total_train_batch
==
self
.
cfg
.
max_iter
:
# used for benchmark
return
s_time
=
time
.
time
()
# optimize the discriminator network
fetches
=
[
...
...
@@ -377,6 +382,12 @@ class STGAN(object):
d_loss_gp
[
0
],
batch_time
))
sys
.
stdout
.
flush
()
batch_id
+=
1
total_train_batch
+=
1
# used for benchmark
# profiler tools
if
self
.
cfg
.
profile
and
epoch_id
==
0
and
batch_id
==
self
.
cfg
.
print_freq
:
profiler
.
reset_profiler
()
elif
self
.
cfg
.
profile
and
epoch_id
==
0
and
batch_id
==
self
.
cfg
.
print_freq
+
5
:
return
if
self
.
cfg
.
run_test
:
image_name
=
fluid
.
data
(
...
...
PaddleCV/PaddleGAN/trainer/StarGAN.py
浏览文件 @
c8545d66
...
...
@@ -17,6 +17,7 @@ from __future__ import print_function
from
network.StarGAN_network
import
StarGAN_model
from
util
import
utility
import
paddle.fluid
as
fluid
from
paddle.fluid
import
profiler
import
sys
import
time
import
copy
...
...
@@ -305,10 +306,12 @@ class StarGAN(object):
build_strategy
=
build_strategy
)
t_time
=
0
total_train_batch
=
0
# used for benchmark
for
epoch_id
in
range
(
self
.
cfg
.
epoch
):
batch_id
=
0
for
data
in
py_reader
():
if
self
.
cfg
.
max_iter
and
total_train_batch
==
self
.
cfg
.
max_iter
:
# used for benchmark
return
s_time
=
time
.
time
()
d_loss_real
,
d_loss_fake
,
d_loss
,
d_loss_cls
,
d_loss_gp
=
exe
.
run
(
dis_trainer_program
,
...
...
@@ -344,6 +347,12 @@ class StarGAN(object):
sys
.
stdout
.
flush
()
batch_id
+=
1
total_train_batch
+=
1
# used for benchmark
# profiler tools
if
self
.
cfg
.
profile
and
epoch_id
==
0
and
batch_id
==
self
.
cfg
.
print_freq
:
profiler
.
reset_profiler
()
elif
self
.
cfg
.
profile
and
epoch_id
==
0
and
batch_id
==
self
.
cfg
.
print_freq
+
5
:
return
if
self
.
cfg
.
run_test
:
image_name
=
fluid
.
data
(
...
...
PaddleCV/PaddleGAN/util/config.py
浏览文件 @
c8545d66
...
...
@@ -85,6 +85,11 @@ def base_parse_args(parser):
add_arg
(
'run_test'
,
bool
,
True
,
"Whether to run test."
)
add_arg
(
'use_gpu'
,
bool
,
True
,
"Whether to use GPU to train."
)
add_arg
(
'profile'
,
bool
,
False
,
"Whether to profile."
)
# NOTE: add args for profiler, used for benchmark
add_arg
(
'profiler_path'
,
str
,
'/tmp/profile'
,
"the profiler output files. (used for benchmark)"
)
add_arg
(
'max_iter'
,
int
,
0
,
"the max iter to train. (used for benchmark)"
)
add_arg
(
'dropout'
,
bool
,
False
,
"Whether to use drouput."
)
add_arg
(
'drop_last'
,
bool
,
False
,
"Whether to drop the last images that cannot form a batch"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录