Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
d60dee05
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看板
未验证
提交
d60dee05
编写于
11月 25, 2020
作者:
Y
Yiqun Liu
提交者:
GitHub
11月 25, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add calcutation and printing of ips for gan models (#4944)
上级
7196201c
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
38 addition
and
22 deletion
+38
-22
PaddleCV/gan/trainer/CycleGAN.py
PaddleCV/gan/trainer/CycleGAN.py
+7
-5
PaddleCV/gan/trainer/Pix2pix.py
PaddleCV/gan/trainer/Pix2pix.py
+7
-5
PaddleCV/gan/trainer/STGAN.py
PaddleCV/gan/trainer/STGAN.py
+7
-5
PaddleCV/gan/trainer/StarGAN.py
PaddleCV/gan/trainer/StarGAN.py
+7
-5
PaddleCV/gan/util/timer.py
PaddleCV/gan/util/timer.py
+10
-2
未找到文件。
PaddleCV/gan/trainer/CycleGAN.py
浏览文件 @
d60dee05
...
...
@@ -338,17 +338,19 @@ class CycleGAN(object):
feed
=
{
"input_A"
:
tensor_A
,
"fake_pool_A"
:
fake_pool_A
})[
0
]
batch_cost_averager
.
record
(
time
.
time
()
-
batch_start
)
batch_cost_averager
.
record
(
time
.
time
()
-
batch_start
,
num_samples
=
self
.
cfg
.
batch_size
)
if
batch_id
%
self
.
cfg
.
print_freq
==
0
:
print
(
"epoch{}: batch{}:
\n\
d_A_loss: {
}; g_A_loss: {}; g_A_cyc_loss: {}; g_A_idt_loss: {
};
\n\
d_B_loss: {
}; g_B_loss: {}; g_B_cyc_loss: {}; g_B_idt_loss: {
};
\n\
reader_cost: {}, Batch_time_cost: {}
"
d_A_loss: {
:.5f}; g_A_loss: {:.5f}; g_A_cyc_loss: {:.5f}; g_A_idt_loss: {:.5f
};
\n\
d_B_loss: {
:.5f}; g_B_loss: {:.5f}; g_B_cyc_loss: {:.5f}; g_B_idt_loss: {:.5f
};
\n\
batch_cost: {:.5f} sec, reader_cost: {:.5f} sec, ips: {:.5f} images/sec
"
.
format
(
epoch_id
,
batch_id
,
d_A_loss
[
0
],
g_A_loss
[
0
],
g_A_cyc_loss
[
0
],
g_A_idt_loss
[
0
],
d_B_loss
[
0
],
g_B_loss
[
0
],
g_B_cyc_loss
[
0
],
g_B_idt_loss
[
0
],
batch_cost_averager
.
get_average
(),
reader_cost_averager
.
get_average
(),
batch_cost_averager
.
get_average
()))
batch_cost_averager
.
get_
ips_
average
()))
reader_cost_averager
.
reset
()
batch_cost_averager
.
reset
()
...
...
PaddleCV/gan/trainer/Pix2pix.py
浏览文件 @
d60dee05
...
...
@@ -292,16 +292,18 @@ class Pix2pix(object):
],
feed
=
tensor
)
batch_cost_averager
.
record
(
time
.
time
()
-
batch_start
)
batch_cost_averager
.
record
(
time
.
time
()
-
batch_start
,
num_samples
=
self
.
cfg
.
batch_size
)
if
batch_id
%
self
.
cfg
.
print_freq
==
0
:
print
(
"epoch{}: batch{}:
\n\
g_loss_gan: {
}; g_loss_l1: {
};
\n\
d_loss_real: {
}; d_loss_fake: {
};
\n\
reader_cost: {}, Batch_time_cost: {}
"
g_loss_gan: {
:.5f}; g_loss_l1: {:.5f
};
\n\
d_loss_real: {
:.5f}; d_loss_fake: {:.5f
};
\n\
batch_cost: {:.5f} sec, reader_cost: {:.5f} sec, ips: {:.5f} images/sec
"
.
format
(
epoch_id
,
batch_id
,
g_loss_gan
[
0
],
g_loss_l1
[
0
],
d_loss_real
[
0
],
d_loss_fake
[
0
],
batch_cost_averager
.
get_average
(),
reader_cost_averager
.
get_average
(),
batch_cost_averager
.
get_average
()))
batch_cost_averager
.
get_
ips_
average
()))
reader_cost_averager
.
reset
()
batch_cost_averager
.
reset
()
...
...
PaddleCV/gan/trainer/STGAN.py
浏览文件 @
d60dee05
...
...
@@ -376,19 +376,21 @@ class STGAN(object):
g_loss_fake
,
g_loss_rec
,
g_loss_cls
=
exe
.
run
(
gen_trainer_program
,
fetch_list
=
d_fetches
,
feed
=
data
)
print
(
"epoch{}: batch{}:
\n\
g_loss_fake: {
}; g_loss_rec: {}; g_loss_cls: {
}"
g_loss_fake: {
:.5f}; g_loss_rec: {:.5f}; g_loss_cls: {:.5f
}"
.
format
(
epoch_id
,
batch_id
,
g_loss_fake
[
0
],
g_loss_rec
[
0
],
g_loss_cls
[
0
]))
batch_cost_averager
.
record
(
time
.
time
()
-
batch_start
)
batch_cost_averager
.
record
(
time
.
time
()
-
batch_start
,
num_samples
=
self
.
cfg
.
batch_size
)
if
(
batch_id
+
1
)
%
self
.
cfg
.
print_freq
==
0
:
print
(
"epoch{}: batch{}:
\n\
d_loss: {
}; d_loss_real: {}; d_loss_fake: {}; d_loss_cls: {}; d_loss_gp: {
}
\n\
reader_cost: {}, Batch_time_cost: {}
"
d_loss: {
:.5f}; d_loss_real: {:.5f}; d_loss_fake: {:.5f}; d_loss_cls: {:.5f}; d_loss_gp: {:.5f
}
\n\
batch_cost: {:.5f} sec, reader_cost: {:.5f} sec, ips: {:.5f} images/sec
"
.
format
(
epoch_id
,
batch_id
,
d_loss
[
0
],
d_loss_real
[
0
],
d_loss_fake
[
0
],
d_loss_cls
[
0
],
d_loss_gp
[
0
],
batch_cost_averager
.
get_average
(),
reader_cost_averager
.
get_average
(),
batch_cost_averager
.
get_average
()))
batch_cost_averager
.
get_
ips_
average
()))
reader_cost_averager
.
reset
()
batch_cost_averager
.
reset
()
...
...
PaddleCV/gan/trainer/StarGAN.py
浏览文件 @
d60dee05
...
...
@@ -345,19 +345,21 @@ class StarGAN(object):
],
feed
=
data
)
print
(
"epoch{}: batch{}:
\n\
g_loss_fake: {
}; g_loss_rec: {}; g_loss_cls: {
}"
g_loss_fake: {
:.5f}; g_loss_rec: {:.5f}; g_loss_cls: {:.5f
}"
.
format
(
epoch_id
,
batch_id
,
g_loss_fake
[
0
],
g_loss_rec
[
0
],
g_loss_cls
[
0
]))
batch_cost_averager
.
record
(
time
.
time
()
-
batch_start
)
batch_cost_averager
.
record
(
time
.
time
()
-
batch_start
,
num_samples
=
self
.
cfg
.
batch_size
)
if
(
batch_id
+
1
)
%
self
.
cfg
.
print_freq
==
0
:
print
(
"epoch{}: batch{}:
\n\
d_loss_real: {
}; d_loss_fake: {}; d_loss_cls: {}; d_loss_gp: {
}
\n\
reader_cost: {}, Batch_time_cost: {}
"
d_loss_real: {
:.5f}; d_loss_fake: {:.5f}; d_loss_cls: {:.5f}; d_loss_gp: {:.5f
}
\n\
batch_cost: {:.5f} sec, reader_cost: {:.5f} sec, ips: {:.5f} images/sec
"
.
format
(
epoch_id
,
batch_id
,
d_loss_real
[
0
],
d_loss_fake
[
0
],
d_loss_cls
[
0
],
d_loss_gp
[
0
],
batch_cost_averager
.
get_average
(),
reader_cost_averager
.
get_average
(),
batch_cost_averager
.
get_average
()))
batch_cost_averager
.
get_
ips_
average
()))
reader_cost_averager
.
reset
()
batch_cost_averager
.
reset
()
...
...
PaddleCV/gan/util/timer.py
浏览文件 @
d60dee05
...
...
@@ -22,12 +22,20 @@ class TimeAverager(object):
def
reset
(
self
):
self
.
_cnt
=
0
self
.
_total_time
=
0
self
.
_total_samples
=
0
def
record
(
self
,
usetime
):
def
record
(
self
,
usetime
,
num_samples
=
None
):
self
.
_cnt
+=
1
self
.
_total_time
+=
usetime
if
num_samples
:
self
.
_total_samples
+=
num_samples
def
get_average
(
self
):
if
self
.
_cnt
==
0
:
return
0
return
self
.
_total_time
/
self
.
_cnt
return
self
.
_total_time
/
float
(
self
.
_cnt
)
def
get_ips_average
(
self
):
if
not
self
.
_total_samples
or
self
.
_cnt
==
0
:
return
0
return
float
(
self
.
_total_samples
)
/
self
.
_total_time
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录