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
812329fa
Commit
812329fa
authored
May 21, 2018
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Properly set reuse in tf.layers to avoid some surprise
parent
18b19d6d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
9 deletions
+16
-9
examples/basics/cifar-convnet.py
examples/basics/cifar-convnet.py
+4
-3
tensorpack/models/batch_norm.py
tensorpack/models/batch_norm.py
+6
-3
tensorpack/models/conv2d.py
tensorpack/models/conv2d.py
+4
-2
tensorpack/models/fc.py
tensorpack/models/fc.py
+2
-1
No files found.
examples/basics/cifar-convnet.py
View file @
812329fa
...
@@ -9,6 +9,7 @@ import os
...
@@ -9,6 +9,7 @@ import os
from
tensorpack
import
*
from
tensorpack
import
*
from
tensorpack.tfutils.summary
import
*
from
tensorpack.tfutils.summary
import
*
from
tensorpack.dataflow
import
dataset
from
tensorpack.dataflow
import
dataset
from
tensorpack.utils.gpu
import
get_num_gpu
"""
"""
A small convnet model for Cifar10 or Cifar100 dataset.
A small convnet model for Cifar10 or Cifar100 dataset.
...
@@ -145,7 +146,7 @@ if __name__ == '__main__':
...
@@ -145,7 +146,7 @@ if __name__ == '__main__':
if
args
.
load
:
if
args
.
load
:
config
.
session_init
=
SaverRestore
(
args
.
load
)
config
.
session_init
=
SaverRestore
(
args
.
load
)
n
r_gpu
=
len
(
args
.
gpu
.
split
(
','
)
)
n
um_gpu
=
get_num_gpu
(
)
trainer
=
QueueInputTrainer
()
if
n
r
_gpu
<=
1
\
trainer
=
QueueInputTrainer
()
if
n
um
_gpu
<=
1
\
else
SyncMultiGPUTrainerParameterServer
(
n
r
_gpu
)
else
SyncMultiGPUTrainerParameterServer
(
n
um
_gpu
)
launch_train_with_config
(
config
,
trainer
)
launch_train_with_config
(
config
,
trainer
)
tensorpack/models/batch_norm.py
View file @
812329fa
...
@@ -110,7 +110,8 @@ def BatchNorm(inputs, axis=None, training=None, momentum=0.9, epsilon=1e-5,
...
@@ -110,7 +110,8 @@ def BatchNorm(inputs, axis=None, training=None, momentum=0.9, epsilon=1e-5,
beta_initializer
=
beta_initializer
,
beta_initializer
=
beta_initializer
,
gamma_initializer
=
gamma_initializer
,
gamma_initializer
=
gamma_initializer
,
virtual_batch_size
=
virtual_batch_size
,
virtual_batch_size
=
virtual_batch_size
,
fused
=
True
fused
=
True
,
_reuse
=
tf
.
get_variable_scope
()
.
reuse
)
)
else
:
else
:
assert
virtual_batch_size
is
None
,
"Feature not supported in this version of TF!"
assert
virtual_batch_size
is
None
,
"Feature not supported in this version of TF!"
...
@@ -120,7 +121,8 @@ def BatchNorm(inputs, axis=None, training=None, momentum=0.9, epsilon=1e-5,
...
@@ -120,7 +121,8 @@ def BatchNorm(inputs, axis=None, training=None, momentum=0.9, epsilon=1e-5,
center
=
center
,
scale
=
scale
,
center
=
center
,
scale
=
scale
,
beta_initializer
=
beta_initializer
,
beta_initializer
=
beta_initializer
,
gamma_initializer
=
gamma_initializer
,
gamma_initializer
=
gamma_initializer
,
fused
=
True
fused
=
True
,
_reuse
=
tf
.
get_variable_scope
()
.
reuse
)
)
xn
=
layer
.
apply
(
inputs
,
training
=
training
,
scope
=
tf
.
get_variable_scope
())
xn
=
layer
.
apply
(
inputs
,
training
=
training
,
scope
=
tf
.
get_variable_scope
())
...
@@ -206,7 +208,8 @@ def BatchRenorm(x, rmax, dmax, momentum=0.9, epsilon=1e-5,
...
@@ -206,7 +208,8 @@ def BatchRenorm(x, rmax, dmax, momentum=0.9, epsilon=1e-5,
'dmax'
:
dmax
},
'dmax'
:
dmax
},
renorm_momentum
=
0.99
,
renorm_momentum
=
0.99
,
gamma_initializer
=
gamma_initializer
,
gamma_initializer
=
gamma_initializer
,
fused
=
False
)
fused
=
False
,
_reuse
=
tf
.
get_variable_scope
()
.
reuse
)
xn
=
layer
.
apply
(
x
,
training
=
ctx
.
is_training
,
scope
=
tf
.
get_variable_scope
())
xn
=
layer
.
apply
(
x
,
training
=
ctx
.
is_training
,
scope
=
tf
.
get_variable_scope
())
if
ctx
.
is_main_training_tower
:
if
ctx
.
is_main_training_tower
:
...
...
tensorpack/models/conv2d.py
View file @
812329fa
...
@@ -63,7 +63,8 @@ def Conv2D(
...
@@ -63,7 +63,8 @@ def Conv2D(
bias_initializer
=
bias_initializer
,
bias_initializer
=
bias_initializer
,
kernel_regularizer
=
kernel_regularizer
,
kernel_regularizer
=
kernel_regularizer
,
bias_regularizer
=
bias_regularizer
,
bias_regularizer
=
bias_regularizer
,
activity_regularizer
=
activity_regularizer
)
activity_regularizer
=
activity_regularizer
,
_reuse
=
tf
.
get_variable_scope
()
.
reuse
)
ret
=
layer
.
apply
(
inputs
,
scope
=
tf
.
get_variable_scope
())
ret
=
layer
.
apply
(
inputs
,
scope
=
tf
.
get_variable_scope
())
ret
=
tf
.
identity
(
ret
,
name
=
'output'
)
ret
=
tf
.
identity
(
ret
,
name
=
'output'
)
...
@@ -164,7 +165,8 @@ def Conv2DTranspose(
...
@@ -164,7 +165,8 @@ def Conv2DTranspose(
bias_initializer
=
bias_initializer
,
bias_initializer
=
bias_initializer
,
kernel_regularizer
=
kernel_regularizer
,
kernel_regularizer
=
kernel_regularizer
,
bias_regularizer
=
bias_regularizer
,
bias_regularizer
=
bias_regularizer
,
activity_regularizer
=
activity_regularizer
)
activity_regularizer
=
activity_regularizer
,
_reuse
=
tf
.
get_variable_scope
()
.
reuse
)
ret
=
layer
.
apply
(
inputs
,
scope
=
tf
.
get_variable_scope
())
ret
=
layer
.
apply
(
inputs
,
scope
=
tf
.
get_variable_scope
())
ret
=
tf
.
identity
(
ret
,
name
=
'output'
)
ret
=
tf
.
identity
(
ret
,
name
=
'output'
)
...
...
tensorpack/models/fc.py
View file @
812329fa
...
@@ -46,7 +46,8 @@ def FullyConnected(
...
@@ -46,7 +46,8 @@ def FullyConnected(
bias_initializer
=
bias_initializer
,
bias_initializer
=
bias_initializer
,
kernel_regularizer
=
kernel_regularizer
,
kernel_regularizer
=
kernel_regularizer
,
bias_regularizer
=
bias_regularizer
,
bias_regularizer
=
bias_regularizer
,
activity_regularizer
=
activity_regularizer
)
activity_regularizer
=
activity_regularizer
,
_reuse
=
tf
.
get_variable_scope
()
.
reuse
)
ret
=
layer
.
apply
(
inputs
,
scope
=
tf
.
get_variable_scope
())
ret
=
layer
.
apply
(
inputs
,
scope
=
tf
.
get_variable_scope
())
ret
=
tf
.
identity
(
ret
,
name
=
'output'
)
ret
=
tf
.
identity
(
ret
,
name
=
'output'
)
...
...
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