Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
0f01ed13
M
models
项目概览
PaddlePaddle
/
models
大约 2 年 前同步成功
通知
232
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看板
未验证
提交
0f01ed13
编写于
1月 02, 2020
作者:
C
ceci3
提交者:
GitHub
1月 02, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix multi cpu (#4131)
* fix elementwise * fix_pix2pix * fix reader
上级
4ffcb3b1
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
17 addition
and
6 deletion
+17
-6
PaddleCV/PaddleGAN/data_reader.py
PaddleCV/PaddleGAN/data_reader.py
+1
-0
PaddleCV/PaddleGAN/trainer/Pix2pix.py
PaddleCV/PaddleGAN/trainer/Pix2pix.py
+7
-6
PaddleCV/PaddleGAN/util/utility.py
PaddleCV/PaddleGAN/util/utility.py
+9
-0
未找到文件。
PaddleCV/PaddleGAN/data_reader.py
浏览文件 @
0f01ed13
...
@@ -630,6 +630,7 @@ class data_reader(object):
...
@@ -630,6 +630,7 @@ class data_reader(object):
batch_size
=
self
.
cfg
.
batch_size
,
batch_size
=
self
.
cfg
.
batch_size
,
mode
=
"TRAIN"
)
mode
=
"TRAIN"
)
reader_test
=
None
reader_test
=
None
id2name
=
None
if
self
.
cfg
.
run_test
:
if
self
.
cfg
.
run_test
:
test_list
=
os
.
path
.
join
(
dataset_dir
,
"test.txt"
)
test_list
=
os
.
path
.
join
(
dataset_dir
,
"test.txt"
)
if
self
.
cfg
.
test_list
is
not
None
:
if
self
.
cfg
.
test_list
is
not
None
:
...
...
PaddleCV/PaddleGAN/trainer/Pix2pix.py
浏览文件 @
0f01ed13
...
@@ -21,6 +21,7 @@ import paddle.fluid as fluid
...
@@ -21,6 +21,7 @@ import paddle.fluid as fluid
from
paddle.fluid
import
profiler
from
paddle.fluid
import
profiler
import
sys
import
sys
import
time
import
time
import
numpy
as
np
class
GTrainer
():
class
GTrainer
():
...
@@ -271,7 +272,6 @@ class Pix2pix(object):
...
@@ -271,7 +272,6 @@ class Pix2pix(object):
return
return
s_time
=
time
.
time
()
s_time
=
time
.
time
()
tensor_A
,
tensor_B
=
tensor
[
0
][
'input_A'
],
tensor
[
0
][
'input_B'
]
# optimize the generator network
# optimize the generator network
g_loss_gan
,
g_loss_l1
,
fake_B_tmp
=
exe
.
run
(
g_loss_gan
,
g_loss_l1
,
fake_B_tmp
=
exe
.
run
(
gen_trainer_program
,
gen_trainer_program
,
...
@@ -281,17 +281,18 @@ class Pix2pix(object):
...
@@ -281,17 +281,18 @@ class Pix2pix(object):
],
],
feed
=
tensor
)
feed
=
tensor
)
devices_num
=
utility
.
get_device_num
(
self
.
cfg
)
fake_per_device
=
int
(
len
(
fake_B_tmp
)
/
devices_num
)
for
dev
in
range
(
devices_num
):
tensor
[
dev
][
'input_fake'
]
=
fake_B_tmp
[
dev
*
fake_per_device
:
(
dev
+
1
)
*
fake_per_device
]
# optimize the discriminator network
# optimize the discriminator network
d_loss_real
,
d_loss_fake
=
exe
.
run
(
dis_trainer_program
,
d_loss_real
,
d_loss_fake
=
exe
.
run
(
dis_trainer_program
,
fetch_list
=
[
fetch_list
=
[
dis_trainer
.
d_loss_real
,
dis_trainer
.
d_loss_real
,
dis_trainer
.
d_loss_fake
dis_trainer
.
d_loss_fake
],
],
feed
=
{
feed
=
tensor
)
"input_A"
:
tensor_A
,
"input_B"
:
tensor_B
,
"input_fake"
:
fake_B_tmp
})
batch_time
=
time
.
time
()
-
s_time
batch_time
=
time
.
time
()
-
s_time
t_time
+=
batch_time
t_time
+=
batch_time
...
...
PaddleCV/PaddleGAN/util/utility.py
浏览文件 @
0f01ed13
...
@@ -425,3 +425,12 @@ def check_version():
...
@@ -425,3 +425,12 @@ def check_version():
except
Exception
as
e
:
except
Exception
as
e
:
print
(
err
)
print
(
err
)
sys
.
exit
(
1
)
sys
.
exit
(
1
)
def
get_device_num
(
args
):
if
args
.
use_gpu
:
gpus
=
os
.
environ
.
get
(
"CUDA_VISIBLE_DEVICES"
,
1
)
gpu_num
=
len
(
gpus
.
split
(
','
))
return
gpu_num
else
:
cpu_num
=
os
.
environ
.
get
(
"CPU_NUM"
,
1
)
return
int
(
cpu_num
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录