Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleGAN
提交
0970de7c
P
PaddleGAN
项目概览
PaddlePaddle
/
PaddleGAN
大约 1 年 前同步成功
通知
97
Star
7254
Fork
1210
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
4
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleGAN
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
4
Issue
4
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
0970de7c
编写于
9月 04, 2020
作者:
L
LielinJiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix save error
上级
abd3250d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
10 addition
and
11 deletion
+10
-11
ppgan/models/base_model.py
ppgan/models/base_model.py
+1
-1
ppgan/models/pix2pix_model.py
ppgan/models/pix2pix_model.py
+1
-1
ppgan/utils/filesystem.py
ppgan/utils/filesystem.py
+8
-9
未找到文件。
ppgan/models/base_model.py
浏览文件 @
0970de7c
...
@@ -93,7 +93,7 @@ class BaseModel(ABC):
...
@@ -93,7 +93,7 @@ class BaseModel(ABC):
This function wraps <forward> function in no_grad() so we don't save intermediate steps for backprop
This function wraps <forward> function in no_grad() so we don't save intermediate steps for backprop
It also calls <compute_visuals> to produce additional visualization results
It also calls <compute_visuals> to produce additional visualization results
"""
"""
with
paddle
.
imperative
.
no_grad
():
with
paddle
.
no_grad
():
self
.
forward
()
self
.
forward
()
self
.
compute_visuals
()
self
.
compute_visuals
()
...
...
ppgan/models/pix2pix_model.py
浏览文件 @
0970de7c
...
@@ -86,7 +86,7 @@ class Pix2PixModel(BaseModel):
...
@@ -86,7 +86,7 @@ class Pix2PixModel(BaseModel):
self
.
fake_B
=
self
.
netG
(
self
.
real_A
)
# G(A)
self
.
fake_B
=
self
.
netG
(
self
.
real_A
)
# G(A)
def
forward_test
(
self
,
input
):
def
forward_test
(
self
,
input
):
input
=
paddle
.
imperative
.
to_variable
(
input
)
input
=
paddle
.
to_tensor
(
input
)
return
self
.
netG
(
input
)
return
self
.
netG
(
input
)
def
backward_D
(
self
):
def
backward_D
(
self
):
...
...
ppgan/utils/filesystem.py
浏览文件 @
0970de7c
...
@@ -3,17 +3,19 @@ import six
...
@@ -3,17 +3,19 @@ import six
import
pickle
import
pickle
import
paddle
import
paddle
def
makedirs
(
dir
):
def
makedirs
(
dir
):
if
not
os
.
path
.
exists
(
dir
):
if
not
os
.
path
.
exists
(
dir
):
os
.
makedirs
(
dir
)
os
.
makedirs
(
dir
)
def
save
(
state_dicts
,
file_name
):
def
save
(
state_dicts
,
file_name
):
def
convert
(
state_dict
):
def
convert
(
state_dict
):
model_dict
=
{}
model_dict
=
{}
for
k
,
v
in
state_dict
.
items
():
for
k
,
v
in
state_dict
.
items
():
if
isinstance
(
v
,
(
paddle
.
framework
.
Variable
,
paddle
.
imperative
.
core
.
VarBase
)):
if
isinstance
(
v
,
(
paddle
.
framework
.
Variable
,
paddle
.
fluid
.
core
.
VarBase
)):
model_dict
[
k
]
=
v
.
numpy
()
model_dict
[
k
]
=
v
.
numpy
()
else
:
else
:
model_dict
[
k
]
=
v
model_dict
[
k
]
=
v
...
@@ -22,14 +24,15 @@ def save(state_dicts, file_name):
...
@@ -22,14 +24,15 @@ def save(state_dicts, file_name):
final_dict
=
{}
final_dict
=
{}
for
k
,
v
in
state_dicts
.
items
():
for
k
,
v
in
state_dicts
.
items
():
if
isinstance
(
v
,
(
paddle
.
framework
.
Variable
,
paddle
.
imperative
.
core
.
VarBase
)):
if
isinstance
(
v
,
(
paddle
.
framework
.
Variable
,
paddle
.
fluid
.
core
.
VarBase
)):
final_dict
=
convert
(
state_dicts
)
final_dict
=
convert
(
state_dicts
)
break
break
elif
isinstance
(
v
,
dict
):
elif
isinstance
(
v
,
dict
):
final_dict
[
k
]
=
convert
(
v
)
final_dict
[
k
]
=
convert
(
v
)
else
:
else
:
final_dict
[
k
]
=
v
final_dict
[
k
]
=
v
with
open
(
file_name
,
'wb'
)
as
f
:
with
open
(
file_name
,
'wb'
)
as
f
:
pickle
.
dump
(
final_dict
,
f
,
protocol
=
2
)
pickle
.
dump
(
final_dict
,
f
,
protocol
=
2
)
...
@@ -39,7 +42,3 @@ def load(file_name):
...
@@ -39,7 +42,3 @@ def load(file_name):
state_dicts
=
pickle
.
load
(
f
)
if
six
.
PY2
else
pickle
.
load
(
state_dicts
=
pickle
.
load
(
f
)
if
six
.
PY2
else
pickle
.
load
(
f
,
encoding
=
'latin1'
)
f
,
encoding
=
'latin1'
)
return
state_dicts
return
state_dicts
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录