Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
seminar-breakout
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shashank Suhas
seminar-breakout
Commits
7e09e551
Commit
7e09e551
authored
Dec 14, 2016
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove g_vs_d in GAN
parent
99362bfd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
16 deletions
+8
-16
examples/GAN/DCGAN-CelebA.py
examples/GAN/DCGAN-CelebA.py
+2
-2
examples/GAN/GAN.py
examples/GAN/GAN.py
+5
-13
examples/GAN/Image2Image.py
examples/GAN/Image2Image.py
+1
-1
No files found.
examples/GAN/DCGAN-CelebA.py
View file @
7e09e551
...
...
@@ -77,7 +77,7 @@ class Model(ModelDesc):
W_init
=
tf
.
truncated_normal_initializer
(
stddev
=
0.02
)):
with
tf
.
variable_scope
(
'gen'
):
image_gen
=
self
.
generator
(
z
)
tf
.
summary
.
image
(
'gen'
,
image_gen
,
max_outputs
=
30
)
tf
.
summary
.
image
(
'gen'
,
image_gen
,
max_outputs
=
30
)
with
tf
.
variable_scope
(
'discrim'
):
vecpos
=
self
.
discriminator
(
image_pos
)
with
tf
.
variable_scope
(
'discrim'
,
reuse
=
True
):
...
...
@@ -144,4 +144,4 @@ if __name__ == '__main__':
config
=
get_config
()
if
args
.
load
:
config
.
session_init
=
SaverRestore
(
args
.
load
)
GANTrainer
(
config
,
g_vs_d
=
1
)
.
train
()
GANTrainer
(
config
)
.
train
()
examples/GAN/GAN.py
View file @
7e09e551
...
...
@@ -11,15 +11,9 @@ from tensorpack.tfutils.summary import summary_moving_average, add_moving_summar
from
tensorpack.dataflow
import
DataFlow
class
GANTrainer
(
FeedfreeTrainer
):
def
__init__
(
self
,
config
,
g_vs_d
=
1
):
def
__init__
(
self
,
config
):
self
.
_input_method
=
QueueInput
(
config
.
dataset
)
super
(
GANTrainer
,
self
)
.
__init__
(
config
)
if
g_vs_d
>
1
:
self
.
_opt_g
=
g_vs_d
self
.
_opt_d
=
1
else
:
self
.
_opt_g
=
1
self
.
_opt_d
=
int
(
1.0
/
g_vs_d
)
def
_setup
(
self
):
super
(
GANTrainer
,
self
)
.
_setup
()
...
...
@@ -32,14 +26,12 @@ class GANTrainer(FeedfreeTrainer):
var_list
=
self
.
model
.
d_vars
,
name
=
'd_op'
)
self
.
gs_incr
=
tf
.
assign_add
(
get_global_step_var
(),
1
,
name
=
'global_step_incr'
)
self
.
summary_op
=
summary_moving_average
()
self
.
d_min
=
tf
.
group
(
self
.
d_min
,
self
.
summary_op
)
self
.
d_min
=
tf
.
group
(
self
.
d_min
,
self
.
summary_op
,
self
.
gs_incr
)
#self.train_op = tf.group(self.g_min, self.d_min)
def
run_step
(
self
):
for
_
in
range
(
self
.
_opt_g
):
self
.
sess
.
run
(
self
.
g_min
)
for
_
in
range
(
self
.
_opt_d
):
self
.
sess
.
run
(
self
.
d_min
)
self
.
sess
.
run
(
self
.
gs_incr
)
self
.
sess
.
run
(
self
.
g_min
)
self
.
sess
.
run
(
self
.
d_min
)
class
RandomZData
(
DataFlow
):
def
__init__
(
self
,
shape
):
...
...
examples/GAN/Image2Image.py
View file @
7e09e551
...
...
@@ -201,4 +201,4 @@ if __name__ == '__main__':
config
=
get_config
()
if
args
.
load
:
config
.
session_init
=
SaverRestore
(
args
.
load
)
GANTrainer
(
config
,
g_vs_d
=
1
)
.
train
()
GANTrainer
(
config
)
.
train
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment