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
224025e3
Commit
224025e3
authored
Feb 17, 2017
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add infogan models, and some small changes.
parent
55f2f5da
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
16 additions
and
11 deletions
+16
-11
examples/DeepQNetwork/README.md
examples/DeepQNetwork/README.md
+1
-1
examples/DeepQNetwork/expreplay.py
examples/DeepQNetwork/expreplay.py
+1
-1
examples/GAN/ConditionalGAN-mnist.py
examples/GAN/ConditionalGAN-mnist.py
+2
-0
examples/GAN/DCGAN-CelebA.py
examples/GAN/DCGAN-CelebA.py
+2
-0
examples/GAN/InfoGAN-mnist.py
examples/GAN/InfoGAN-mnist.py
+2
-0
examples/GAN/README.md
examples/GAN/README.md
+1
-3
tensorpack/dataflow/imgaug/noname.py
tensorpack/dataflow/imgaug/noname.py
+2
-2
tensorpack/models/batch_norm.py
tensorpack/models/batch_norm.py
+3
-3
tensorpack/tfutils/modelutils.py
tensorpack/tfutils/modelutils.py
+1
-1
tensorpack/train/trainer.py
tensorpack/train/trainer.py
+1
-0
No files found.
examples/DeepQNetwork/README.md
View file @
224025e3
...
@@ -19,7 +19,7 @@ Claimed performance in the paper can be reproduced, on several games I've tested
...
@@ -19,7 +19,7 @@ Claimed performance in the paper can be reproduced, on several games I've tested


DQN typically took
2
days of training to reach a score of 400 on breakout game (same as the paper).
DQN typically took
1.5
days of training to reach a score of 400 on breakout game (same as the paper).
My Batch-A3C implementation only took <2 hours.
My Batch-A3C implementation only took <2 hours.
Both were trained on one GPU with an extra GPU for simulation.
Both were trained on one GPU with an extra GPU for simulation.
...
...
examples/DeepQNetwork/expreplay.py
View file @
224025e3
...
@@ -102,7 +102,7 @@ class ExpReplay(DataFlow, Callback):
...
@@ -102,7 +102,7 @@ class ExpReplay(DataFlow, Callback):
# self.mem.append(deepcopy(self.mem[0]))
# self.mem.append(deepcopy(self.mem[0]))
# return
# return
old_s
=
self
.
player
.
current_state
()
old_s
=
self
.
player
.
current_state
()
if
self
.
rng
.
rand
()
<=
self
.
exploration
:
if
self
.
rng
.
rand
()
<=
self
.
exploration
or
len
(
self
.
mem
)
<
5
:
act
=
self
.
rng
.
choice
(
range
(
self
.
num_actions
))
act
=
self
.
rng
.
choice
(
range
(
self
.
num_actions
))
else
:
else
:
# build a history state
# build a history state
...
...
examples/GAN/ConditionalGAN-mnist.py
View file @
224025e3
...
@@ -21,6 +21,8 @@ To train:
...
@@ -21,6 +21,8 @@ To train:
To visualize:
To visualize:
./ConditionalGAN-mnist.py --sample --load path/to/model
./ConditionalGAN-mnist.py --sample --load path/to/model
A pretrained model is at https://drive.google.com/open?id=0B9IPQTvr2BBkLUF2M0RXU1NYSkE
"""
"""
BATCH
=
128
BATCH
=
128
...
...
examples/GAN/DCGAN-CelebA.py
View file @
224025e3
...
@@ -23,6 +23,8 @@ from GAN import GANTrainer, RandomZData, GANModelDesc
...
@@ -23,6 +23,8 @@ from GAN import GANTrainer, RandomZData, GANModelDesc
You can also train on other images (just use any directory of jpg files in
You can also train on other images (just use any directory of jpg files in
`--data`). But you may need to change the preprocessing steps in `get_data()`.
`--data`). But you may need to change the preprocessing steps in `get_data()`.
A pretrained model on CelebA is at https://drive.google.com/open?id=0B9IPQTvr2BBkLUF2M0RXU1NYSkE
"""
"""
SHAPE
=
64
SHAPE
=
64
...
...
examples/GAN/InfoGAN-mnist.py
View file @
224025e3
...
@@ -23,6 +23,8 @@ To train:
...
@@ -23,6 +23,8 @@ To train:
To visualize:
To visualize:
./InfoGAN-mnist.py --sample --load path/to/model
./InfoGAN-mnist.py --sample --load path/to/model
A pretrained model is at https://drive.google.com/open?id=0B9IPQTvr2BBkLUF2M0RXU1NYSkE
"""
"""
BATCH
=
128
BATCH
=
128
...
...
examples/GAN/README.md
View file @
224025e3
...
@@ -12,14 +12,12 @@ Reproduce the following GAN-related methods:
...
@@ -12,14 +12,12 @@ Reproduce the following GAN-related methods:
+
[
Wasserstein GAN
](
https://arxiv.org/abs/1701.07875
)
+
[
Wasserstein GAN
](
https://arxiv.org/abs/1701.07875
)
Please see the __docstring__ in each script for detailed usage.
Please see the __docstring__ in each script for detailed usage
and pretrained models
.
## DCGAN-CelebA.py
## DCGAN-CelebA.py
Reproduce DCGAN following the setup in
[
dcgan.torch
](
https://github.com/soumith/dcgan.torch
)
.
Reproduce DCGAN following the setup in
[
dcgan.torch
](
https://github.com/soumith/dcgan.torch
)
.
Play with the
[
pretrained model
](
https://drive.google.com/drive/folders/0B9IPQTvr2BBkLUF2M0RXU1NYSkE?usp=sharing
)
on CelebA face dataset:
+
Generated samples
+
Generated samples


...
...
tensorpack/dataflow/imgaug/noname.py
View file @
224025e3
...
@@ -73,7 +73,7 @@ class ResizeShortestEdge(ImageAugmentor):
...
@@ -73,7 +73,7 @@ class ResizeShortestEdge(ImageAugmentor):
keeping the aspect ratio.
keeping the aspect ratio.
"""
"""
def
__init__
(
self
,
size
):
def
__init__
(
self
,
size
,
interp
=
cv2
.
INTER_LINEAR
):
"""
"""
Args:
Args:
size (int): the size to resize the shortest edge to.
size (int): the size to resize the shortest edge to.
...
@@ -85,7 +85,7 @@ class ResizeShortestEdge(ImageAugmentor):
...
@@ -85,7 +85,7 @@ class ResizeShortestEdge(ImageAugmentor):
h
,
w
=
img
.
shape
[:
2
]
h
,
w
=
img
.
shape
[:
2
]
scale
=
self
.
size
/
min
(
h
,
w
)
scale
=
self
.
size
/
min
(
h
,
w
)
desSize
=
map
(
int
,
[
scale
*
w
,
scale
*
h
])
desSize
=
map
(
int
,
[
scale
*
w
,
scale
*
h
])
ret
=
cv2
.
resize
(
img
,
tuple
(
desSize
),
interpolation
=
cv2
.
INTER_LINEAR
)
ret
=
cv2
.
resize
(
img
,
tuple
(
desSize
),
interpolation
=
self
.
interp
)
if
img
.
ndim
==
3
and
ret
.
ndim
==
2
:
if
img
.
ndim
==
3
and
ret
.
ndim
==
2
:
ret
=
ret
[:,
:,
np
.
newaxis
]
ret
=
ret
[:,
:,
np
.
newaxis
]
return
ret
return
ret
...
...
tensorpack/models/batch_norm.py
View file @
224025e3
...
@@ -241,11 +241,11 @@ def BatchRenorm(x, rmax, dmax, decay=0.9, epsilon=1e-5,
...
@@ -241,11 +241,11 @@ def BatchRenorm(x, rmax, dmax, decay=0.9, epsilon=1e-5,
if
use_local_stat
:
if
use_local_stat
:
xn
,
batch_mean
,
batch_var
=
tf
.
nn
.
fused_batch_norm
(
x
,
gamma
,
beta
,
xn
,
batch_mean
,
batch_var
=
tf
.
nn
.
fused_batch_norm
(
x
,
gamma
,
beta
,
epsilon
=
epsilon
,
is_training
=
True
)
epsilon
=
epsilon
,
is_training
=
True
)
moving_sigma
=
tf
.
sqrt
(
moving_var
,
'
sigma'
)
inv_sigma
=
tf
.
rsqrt
(
moving_var
,
'inv_
sigma'
)
r
=
tf
.
stop_gradient
(
tf
.
clip_by_value
(
r
=
tf
.
stop_gradient
(
tf
.
clip_by_value
(
tf
.
sqrt
(
batch_var
/
moving_var
)
,
1.0
/
rmax
,
rmax
))
tf
.
sqrt
(
batch_var
)
*
inv_sigma
,
1.0
/
rmax
,
rmax
))
d
=
tf
.
stop_gradient
(
tf
.
clip_by_value
(
d
=
tf
.
stop_gradient
(
tf
.
clip_by_value
(
(
batch_mean
-
moving_mean
)
/
moving
_sigma
,
(
batch_mean
-
moving_mean
)
*
inv
_sigma
,
-
dmax
,
dmax
))
-
dmax
,
dmax
))
xn
=
xn
*
r
+
d
xn
=
xn
*
r
+
d
else
:
else
:
...
...
tensorpack/tfutils/modelutils.py
View file @
224025e3
...
@@ -77,7 +77,7 @@ def apply_slim_collections(cost):
...
@@ -77,7 +77,7 @@ def apply_slim_collections(cost):
if
ctx
is
not
None
and
ctx
.
is_main_training_tower
:
if
ctx
is
not
None
and
ctx
.
is_main_training_tower
:
non_grad_updates
=
set
(
tf
.
get_collection
(
tf
.
GraphKeys
.
UPDATE_OPS
))
non_grad_updates
=
set
(
tf
.
get_collection
(
tf
.
GraphKeys
.
UPDATE_OPS
))
if
non_grad_updates
:
if
non_grad_updates
:
logger
.
info
(
"Applying UPDATE_OPS collection on cost."
)
logger
.
info
(
"Applying UPDATE_OPS collection
from the first tower
on cost."
)
with
tf
.
control_dependencies
(
non_grad_updates
):
with
tf
.
control_dependencies
(
non_grad_updates
):
cost
=
tf
.
identity
(
cost
,
name
=
'cost_with_update'
)
cost
=
tf
.
identity
(
cost
,
name
=
'cost_with_update'
)
return
cost
return
cost
tensorpack/train/trainer.py
View file @
224025e3
...
@@ -40,6 +40,7 @@ class PredictorFactory(object):
...
@@ -40,6 +40,7 @@ class PredictorFactory(object):
def
get_name_in_tower
(
name
):
def
get_name_in_tower
(
name
):
return
PREDICT_TOWER
+
str
(
tower
)
+
'/'
+
name
return
PREDICT_TOWER
+
str
(
tower
)
+
'/'
+
name
def
maybe_inside_tower
(
name
):
def
maybe_inside_tower
(
name
):
name
=
get_op_tensor_name
(
name
)[
0
]
name
=
get_op_tensor_name
(
name
)[
0
]
if
name
in
placeholder_names
:
if
name
in
placeholder_names
:
...
...
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