Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
531e8354
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
531e8354
编写于
11月 27, 2016
作者:
W
wangyang59
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
changes to demo/gan following lzhao4ever comments
上级
9a02bd41
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
18 addition
and
11 deletion
+18
-11
demo/gan/.gitignore
demo/gan/.gitignore
+3
-0
demo/gan/gan_conf.py
demo/gan/gan_conf.py
+3
-0
demo/gan/gan_trainer.py
demo/gan/gan_trainer.py
+12
-11
未找到文件。
demo/gan/.gitignore
浏览文件 @
531e8354
output/
uniform_params/
cifar_params/
mnist_params/
*.png
.pydevproject
.project
...
...
demo/gan/gan_conf.py
浏览文件 @
531e8354
...
...
@@ -24,6 +24,9 @@ is_discriminator_training = mode == "discriminator_training"
is_generator
=
mode
==
"generator"
is_discriminator
=
mode
==
"discriminator"
# The network structure below follows the ref https://arxiv.org/abs/1406.2661
# Here we used two hidden layers and batch_norm
print
(
'mode=%s'
%
mode
)
# the dim of the noise (z) as the input of the generator network
noise_dim
=
10
...
...
demo/gan/gan_trainer.py
浏览文件 @
531e8354
...
...
@@ -90,10 +90,8 @@ def load_mnist_data(imageFile):
data
=
numpy
.
zeros
((
n
,
28
*
28
),
dtype
=
"float32"
)
for
i
in
range
(
n
):
pixels
=
[]
for
j
in
range
(
28
*
28
):
pixels
.
append
(
float
(
ord
(
f
.
read
(
1
)))
/
255.0
*
2.0
-
1.0
)
data
[
i
,
:]
=
pixels
pixels
=
numpy
.
fromfile
(
f
,
'ubyte'
,
count
=
28
*
28
)
data
[
i
,
:]
=
pixels
/
255.0
*
2.0
-
1.0
f
.
close
()
return
data
...
...
@@ -129,7 +127,7 @@ def merge(images, size):
((
images
[
idx
,
:].
reshape
((
h
,
w
,
c
),
order
=
"F"
).
transpose
(
1
,
0
,
2
)
+
1.0
)
/
2.0
*
255.0
)
return
img
.
astype
(
'uint8'
)
def
save
I
mages
(
images
,
path
):
def
save
_i
mages
(
images
,
path
):
merged_img
=
merge
(
images
,
[
8
,
8
])
if
merged_img
.
shape
[
2
]
==
1
:
im
=
Image
.
fromarray
(
numpy
.
squeeze
(
merged_img
)).
convert
(
'RGB'
)
...
...
@@ -207,9 +205,15 @@ def main():
useGpu
=
args
.
useGpu
assert
dataSource
in
[
"mnist"
,
"cifar"
,
"uniform"
]
assert
useGpu
in
[
"0"
,
"1"
]
if
not
os
.
path
.
exists
(
"./%s_samples/"
%
dataSource
):
os
.
makedirs
(
"./%s_samples/"
%
dataSource
)
if
not
os
.
path
.
exists
(
"./%s_params/"
%
dataSource
):
os
.
makedirs
(
"./%s_params/"
%
dataSource
)
api
.
initPaddle
(
'--use_gpu='
+
useGpu
,
'--dot_period=10'
,
'--log_period=100'
,
'--gpu_id='
+
args
.
gpuId
)
'--gpu_id='
+
args
.
gpuId
,
'--save_dir='
+
"./%s_params/"
%
dataSource
)
if
dataSource
==
"uniform"
:
conf
=
"gan_conf.py"
...
...
@@ -231,9 +235,6 @@ def main():
else
:
data_np
=
load_uniform_data
()
if
not
os
.
path
.
exists
(
"./%s_samples/"
%
dataSource
):
os
.
makedirs
(
"./%s_samples/"
%
dataSource
)
# this create a gradient machine for discriminator
dis_training_machine
=
api
.
GradientMachine
.
createFromConfigProto
(
dis_conf
.
model_config
)
...
...
@@ -321,7 +322,7 @@ def main():
if
dataSource
==
"uniform"
:
plot2DScatter
(
fake_samples
,
"./%s_samples/train_pass%s.png"
%
(
dataSource
,
train_pass
))
else
:
save
I
mages
(
fake_samples
,
"./%s_samples/train_pass%s.png"
%
(
dataSource
,
train_pass
))
save
_i
mages
(
fake_samples
,
"./%s_samples/train_pass%s.png"
%
(
dataSource
,
train_pass
))
dis_trainer
.
finishTrain
()
gen_trainer
.
finishTrain
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录