Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
1c52e005
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看板
提交
1c52e005
编写于
12月 18, 2019
作者:
u010070587
提交者:
ruri
12月 18, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add PaddleGAN ce (#4079)
上级
d127132c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
72 addition
and
4 deletion
+72
-4
PaddleCV/PaddleGAN/trainer/CycleGAN.py
PaddleCV/PaddleGAN/trainer/CycleGAN.py
+33
-1
PaddleCV/PaddleGAN/trainer/DCGAN.py
PaddleCV/PaddleGAN/trainer/DCGAN.py
+18
-1
PaddleCV/PaddleGAN/trainer/Pix2pix.py
PaddleCV/PaddleGAN/trainer/Pix2pix.py
+21
-2
未找到文件。
PaddleCV/PaddleGAN/trainer/CycleGAN.py
浏览文件 @
1c52e005
...
...
@@ -207,7 +207,10 @@ class CycleGAN(object):
type
=
int
,
default
=
3
,
help
=
"only used when CycleGAN discriminator is nlayers"
)
parser
.
add_argument
(
'--enable_ce'
,
action
=
'store_true'
,
help
=
"if set, run the tasks with continuous evaluation logs"
)
return
parser
def
__init__
(
self
,
...
...
@@ -237,6 +240,9 @@ class CycleGAN(object):
name
=
'fake_pool_A'
,
shape
=
data_shape
,
dtype
=
'float32'
)
fake_pool_B
=
fluid
.
data
(
name
=
'fake_pool_B'
,
shape
=
data_shape
,
dtype
=
'float32'
)
# used for continuous evaluation
if
self
.
cfg
.
enable_ce
:
fluid
.
default_startup_program
().
random_seed
=
90
A_py_reader
=
fluid
.
io
.
PyReader
(
feed_list
=
[
input_A
],
...
...
@@ -344,6 +350,9 @@ class CycleGAN(object):
sys
.
stdout
.
flush
()
batch_id
+=
1
# used for continuous evaluation
if
self
.
cfg
.
enable_ce
and
batch_id
==
10
:
break
if
self
.
cfg
.
run_test
:
A_image_name
=
fluid
.
data
(
...
...
@@ -390,3 +399,26 @@ class CycleGAN(object):
"net_DA"
)
utility
.
checkpoints
(
epoch_id
,
self
.
cfg
,
exe
,
d_B_trainer
,
"net_DB"
)
# used for continuous evaluation
if
self
.
cfg
.
enable_ce
:
device_num
=
fluid
.
core
.
get_cuda_device_count
(
)
if
self
.
cfg
.
use_gpu
else
1
print
(
"kpis
\t
cyclegan_g_A_loss_card{}
\t
{}"
.
format
(
device_num
,
g_A_loss
[
0
]))
print
(
"kpis
\t
cyclegan_g_A_cyc_loss_card{}
\t
{}"
.
format
(
device_num
,
g_A_cyc_loss
[
0
]))
print
(
"kpis
\t
cyclegan_g_A_idt_loss_card{}
\t
{}"
.
format
(
device_num
,
g_A_idt_loss
[
0
]))
print
(
"kpis
\t
cyclegan_d_A_loss_card{}
\t
{}"
.
format
(
device_num
,
d_A_loss
[
0
]))
print
(
"kpis
\t
cyclegan_g_B_loss_card{}
\t
{}"
.
format
(
device_num
,
g_B_loss
[
0
]))
print
(
"kpis
\t
cyclegan_g_B_cyc_loss_card{}
\t
{}"
.
format
(
device_num
,
g_B_cyc_loss
[
0
]))
print
(
"kpis
\t
cyclegan_g_B_idt_loss_card{}
\t
{}"
.
format
(
device_num
,
g_B_idt_loss
[
0
]))
print
(
"kpis
\t
cyclegan_d_B_loss_card{}
\t
{}"
.
format
(
device_num
,
d_B_loss
[
0
]))
print
(
"kpis
\t
cyclegan_Batch_time_cost_card{}
\t
{}"
.
format
(
device_num
,
batch_time
))
PaddleCV/PaddleGAN/trainer/DCGAN.py
浏览文件 @
1c52e005
...
...
@@ -27,6 +27,7 @@ import matplotlib
matplotlib
.
use
(
'agg'
)
import
matplotlib.pyplot
as
plt
import
paddle.fluid
as
fluid
import
random
class
GTrainer
():
...
...
@@ -78,7 +79,10 @@ class DCGAN(object):
def
add_special_args
(
self
,
parser
):
parser
.
add_argument
(
'--noise_size'
,
type
=
int
,
default
=
100
,
help
=
"the noise dimension"
)
parser
.
add_argument
(
'--enable_ce'
,
action
=
'store_true'
,
help
=
"if set, run the tasks with continuous evaluation logs"
)
return
parser
def
__init__
(
self
,
cfg
=
None
,
train_reader
=
None
):
...
...
@@ -90,6 +94,11 @@ class DCGAN(object):
noise
=
fluid
.
data
(
name
=
'noise'
,
shape
=
[
None
,
self
.
cfg
.
noise_size
],
dtype
=
'float32'
)
label
=
fluid
.
data
(
name
=
'label'
,
shape
=
[
None
,
1
],
dtype
=
'float32'
)
# used for continuous evaluation
if
self
.
cfg
.
enable_ce
:
fluid
.
default_startup_program
().
random_seed
=
90
random
.
seed
(
0
)
np
.
random
.
seed
(
0
)
g_trainer
=
GTrainer
(
noise
,
label
,
self
.
cfg
)
d_trainer
=
DTrainer
(
img
,
label
,
self
.
cfg
)
...
...
@@ -200,3 +209,11 @@ class DCGAN(object):
if
self
.
cfg
.
save_checkpoints
:
utility
.
checkpoints
(
epoch_id
,
self
.
cfg
,
exe
,
g_trainer
,
"net_G"
)
utility
.
checkpoints
(
epoch_id
,
self
.
cfg
,
exe
,
d_trainer
,
"net_D"
)
# used for continuous evaluation
if
self
.
cfg
.
enable_ce
:
device_num
=
fluid
.
core
.
get_cuda_device_count
(
)
if
self
.
cfg
.
use_gpu
else
1
print
(
"kpis
\t
dcgan_d_loss_card{}
\t
{}"
.
format
(
device_num
,
d_loss
[
0
]))
print
(
"kpis
\t
dcgan_g_loss_card{}
\t
{}"
.
format
(
device_num
,
g_loss
[
0
]))
print
(
"kpis
\t
dcgan_Batch_time_cost_card{}
\t
{}"
.
format
(
device_num
,
batch_time
))
PaddleCV/PaddleGAN/trainer/Pix2pix.py
浏览文件 @
1c52e005
...
...
@@ -196,7 +196,10 @@ class Pix2pix(object):
type
=
int
,
default
=
3
,
help
=
"only used when Pix2pix discriminator is nlayers"
)
parser
.
add_argument
(
'--enable_ce'
,
action
=
'store_true'
,
help
=
"if set, run the tasks with continuous evaluation logs"
)
return
parser
def
__init__
(
self
,
...
...
@@ -218,6 +221,9 @@ class Pix2pix(object):
input_B
=
fluid
.
data
(
name
=
'input_B'
,
shape
=
data_shape
,
dtype
=
'float32'
)
input_fake
=
fluid
.
data
(
name
=
'input_fake'
,
shape
=
data_shape
,
dtype
=
'float32'
)
# used for continuous evaluation
if
self
.
cfg
.
enable_ce
:
fluid
.
default_startup_program
().
random_seed
=
90
loader
=
fluid
.
io
.
DataLoader
.
from_generator
(
feed_list
=
[
input_A
,
input_B
],
...
...
@@ -261,7 +267,7 @@ class Pix2pix(object):
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
if
self
.
cfg
.
max_iter
and
total_train_batch
==
self
.
cfg
.
max_iter
:
# used for benchmark
return
s_time
=
time
.
time
()
...
...
@@ -336,3 +342,16 @@ class Pix2pix(object):
"net_G"
)
utility
.
checkpoints
(
epoch_id
,
self
.
cfg
,
exe
,
dis_trainer
,
"net_D"
)
if
self
.
cfg
.
enable_ce
:
device_num
=
fluid
.
core
.
get_cuda_device_count
(
)
if
self
.
cfg
.
use_gpu
else
1
print
(
"kpis
\t
pix2pix_g_loss_gan_card{}
\t
{}"
.
format
(
device_num
,
g_loss_gan
[
0
]))
print
(
"kpis
\t
pix2pix_g_loss_l1_card{}
\t
{}"
.
format
(
device_num
,
g_loss_l1
[
0
]))
print
(
"kpis
\t
pix2pix_d_loss_real_card{}
\t
{}"
.
format
(
device_num
,
d_loss_real
[
0
]))
print
(
"kpis
\t
pix2pix_d_loss_fake_card{}
\t
{}"
.
format
(
device_num
,
d_loss_fake
[
0
]))
print
(
"kpis
\t
pix2pix_Batch_time_cost_card{}
\t
{}"
.
format
(
device_num
,
batch_time
))
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录