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
9fc5d856
Commit
9fc5d856
authored
Dec 07, 2016
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update summary API to latest
parent
1f02847d
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
30 additions
and
27 deletions
+30
-27
examples/DoReFa-Net/svhn-digit-dorefa.py
examples/DoReFa-Net/svhn-digit-dorefa.py
+1
-1
examples/GAN/DCGAN-CelebA.py
examples/GAN/DCGAN-CelebA.py
+1
-1
examples/GAN/GAN.py
examples/GAN/GAN.py
+2
-2
examples/GAN/InfoGAN-mnist.py
examples/GAN/InfoGAN-mnist.py
+1
-1
examples/SpatialTransformer/mnist-addition.py
examples/SpatialTransformer/mnist-addition.py
+1
-1
examples/cifar-convnet.py
examples/cifar-convnet.py
+1
-1
examples/mnist-convnet.py
examples/mnist-convnet.py
+1
-1
examples/svhn-digit-convnet.py
examples/svhn-digit-convnet.py
+1
-1
tensorpack/callbacks/stats.py
tensorpack/callbacks/stats.py
+4
-1
tensorpack/tfutils/gradproc.py
tensorpack/tfutils/gradproc.py
+1
-1
tensorpack/tfutils/summary.py
tensorpack/tfutils/summary.py
+12
-13
tensorpack/tfutils/symbolic_functions.py
tensorpack/tfutils/symbolic_functions.py
+2
-1
tensorpack/train/base.py
tensorpack/train/base.py
+2
-2
No files found.
examples/DoReFa-Net/svhn-digit-dorefa.py
View file @
9fc5d856
...
...
@@ -153,7 +153,7 @@ def get_config():
global_step
=
get_global_step_var
(),
decay_steps
=
data_train
.
size
()
*
100
,
decay_rate
=
0.5
,
staircase
=
True
,
name
=
'learning_rate'
)
tf
.
s
calar_summary
(
'learning_rate
'
,
lr
)
tf
.
s
ummary
.
scalar
(
'lr
'
,
lr
)
return
TrainConfig
(
dataset
=
data_train
,
...
...
examples/GAN/DCGAN-CelebA.py
View file @
9fc5d856
...
...
@@ -75,7 +75,7 @@ class Model(ModelDesc):
W_init
=
tf
.
truncated_normal_initializer
(
stddev
=
0.02
)):
with
tf
.
variable_scope
(
'gen'
):
image_gen
=
self
.
generator
(
z
)
tf
.
image_summary
(
'gen'
,
image_gen
,
max_images
=
30
)
tf
.
summary
.
image
(
'gen'
,
image_gen
,
max_images
=
30
)
with
tf
.
variable_scope
(
'discrim'
):
vecpos
=
self
.
discriminator
(
image_pos
)
with
tf
.
variable_scope
(
'discrim'
,
reuse
=
True
):
...
...
examples/GAN/GAN.py
View file @
9fc5d856
...
...
@@ -52,8 +52,8 @@ class RandomZData(DataFlow):
def
build_GAN_losses
(
vecpos
,
vecneg
):
sigmpos
=
tf
.
sigmoid
(
vecpos
)
sigmneg
=
tf
.
sigmoid
(
vecneg
)
tf
.
histogram_summary
(
'sigmoid-pos'
,
sigmpos
)
tf
.
histogram_summary
(
'sigmoid-neg'
,
sigmneg
)
tf
.
summary
.
histogram
(
'sigmoid-pos'
,
sigmpos
)
tf
.
summary
.
histogram
(
'sigmoid-neg'
,
sigmneg
)
d_loss_pos
=
tf
.
reduce_mean
(
tf
.
nn
.
sigmoid_cross_entropy_with_logits
(
vecpos
,
tf
.
ones_like
(
vecpos
)),
name
=
'd_CE_loss_pos'
)
...
...
examples/GAN/InfoGAN-mnist.py
View file @
9fc5d856
...
...
@@ -66,7 +66,7 @@ class Model(ModelDesc):
W_init
=
tf
.
truncated_normal_initializer
(
stddev
=
0.02
)):
with
tf
.
variable_scope
(
'gen'
):
image_gen
=
self
.
generator
(
z
)
tf
.
image_summary
(
'gen'
,
image_gen
,
max_images
=
30
)
tf
.
summary
.
image
(
'gen'
,
image_gen
,
max_images
=
30
)
with
tf
.
variable_scope
(
'discrim'
):
vecpos
,
_
=
self
.
discriminator
(
image_pos
)
with
tf
.
variable_scope
(
'discrim'
,
reuse
=
True
):
...
...
examples/SpatialTransformer/mnist-addition.py
View file @
9fc5d856
...
...
@@ -61,7 +61,7 @@ class Model(ModelDesc):
transform1
=
tf
.
concat
(
1
,
[
padded1
[:,:,:,
0
],
padded1
[:,:,:,
1
]])
transform2
=
tf
.
concat
(
1
,
[
padded2
[:,:,:,
0
],
padded2
[:,:,:,
1
]])
stacked
=
tf
.
concat
(
2
,
[
img_orig
,
transform1
,
transform2
],
'viz'
)
tf
.
image_summary
(
'visualize'
,
tf
.
summary
.
image
(
'visualize'
,
tf
.
expand_dims
(
stacked
,
-
1
),
max_images
=
30
)
sampled
=
tf
.
concat
(
3
,
[
sampled1
,
sampled2
],
'sampled_concat'
)
...
...
examples/cifar-convnet.py
View file @
9fc5d856
...
...
@@ -38,7 +38,7 @@ class Model(ModelDesc):
keep_prob
=
tf
.
constant
(
0.5
if
is_training
else
1.0
)
if
is_training
:
tf
.
image_summary
(
"train_image"
,
image
,
10
)
tf
.
summary
.
image
(
"train_image"
,
image
,
10
)
image
=
image
/
4.0
# just to make range smaller
with
argscope
(
Conv2D
,
nl
=
BNReLU
,
use_bias
=
False
,
kernel_shape
=
3
):
...
...
examples/mnist-convnet.py
View file @
9fc5d856
...
...
@@ -104,7 +104,7 @@ def get_config():
# This will also put the summary in tensorboard,stat.json and print in
# terminal, but without the moving average
tf
.
s
calar_summary
(
'learning_rate
'
,
lr
)
tf
.
s
ummary
.
scalar
(
'lr
'
,
lr
)
# get the config which contains everything necessary in a training
return
TrainConfig
(
...
...
examples/svhn-digit-convnet.py
View file @
9fc5d856
...
...
@@ -92,7 +92,7 @@ def get_config():
global_step
=
get_global_step_var
(),
decay_steps
=
data_train
.
size
()
*
60
,
decay_rate
=
0.2
,
staircase
=
True
,
name
=
'learning_rate'
)
tf
.
s
calar_summary
(
'learning_rate
'
,
lr
)
tf
.
s
ummary
.
scalar
(
'lr
'
,
lr
)
return
TrainConfig
(
dataset
=
data_train
,
...
...
tensorpack/callbacks/stats.py
View file @
9fc5d856
# -*- coding: utf-8 -*-
# File: stat.py
# File: stat
s
.py
# Author: Yuxin Wu <ppwwyyxxc@gmail.com>
import
tensorflow
as
tf
...
...
@@ -40,6 +40,9 @@ class StatHolder(object):
:param k: name
:param v: value
"""
suffix
=
'-summary'
if
k
.
endswith
(
suffix
):
k
=
k
[:
-
len
(
suffix
)]
self
.
stat_now
[
k
]
=
float
(
v
)
def
set_print_tag
(
self
,
print_tag
):
...
...
tensorpack/tfutils/gradproc.py
View file @
9fc5d856
...
...
@@ -110,7 +110,7 @@ class SummaryGradient(MapGradient):
name
=
var
.
op
.
name
if
name
not
in
_summaried_gradient
:
_summaried_gradient
.
add
(
name
)
tf
.
histogram_summary
(
name
+
'/
grad'
,
grad
)
tf
.
summary
.
histogram
(
name
+
'-
grad'
,
grad
)
add_moving_summary
(
rms
(
grad
,
name
=
name
+
'/rms'
))
return
grad
...
...
tensorpack/tfutils/summary.py
View file @
9fc5d856
...
...
@@ -38,11 +38,10 @@ def add_activation_summary(x, name=None):
"Summary a scalar with histogram? Maybe use scalar instead. FIXME!"
if
name
is
None
:
name
=
x
.
name
with
tf
.
name_scope
(
'act_summary'
):
tf
.
histogram_summary
(
name
+
'/activation'
,
x
)
tf
.
scalar_summary
(
name
+
'/activation_sparsity'
,
tf
.
nn
.
zero_fraction
(
x
))
tf
.
scalar_summary
(
name
+
'/activation_rms'
,
rms
(
x
))
with
tf
.
name_scope
(
'activation-summary'
):
tf
.
summary
.
histogram
(
name
,
x
)
tf
.
summary
.
scalar
(
name
+
'-sparsity'
,
tf
.
nn
.
zero_fraction
(
x
))
tf
.
summary
.
scalar
(
name
+
'-rms'
,
rms
(
x
))
def
add_param_summary
(
summary_lists
):
"""
...
...
@@ -59,25 +58,25 @@ def add_param_summary(summary_lists):
name
=
var
.
name
.
replace
(
':0'
,
''
)
if
action
==
'scalar'
:
assert
ndim
==
0
,
"Scalar summary on high-dimension data. Maybe you want 'mean'?"
tf
.
s
calar_summary
(
name
,
var
)
tf
.
s
ummary
.
scalar
(
name
,
var
)
return
assert
ndim
>
0
,
"Cannot perform {} summary on scalar data"
.
format
(
action
)
if
action
==
'histogram'
:
tf
.
histogram_summary
(
name
,
var
)
tf
.
summary
.
histogram
(
name
,
var
)
return
if
action
==
'sparsity'
:
tf
.
s
calar_summary
(
name
+
'/
sparsity'
,
tf
.
nn
.
zero_fraction
(
var
))
tf
.
s
ummary
.
scalar
(
name
+
'-
sparsity'
,
tf
.
nn
.
zero_fraction
(
var
))
return
if
action
==
'mean'
:
tf
.
s
calar_summary
(
name
+
'/
mean'
,
tf
.
reduce_mean
(
var
))
tf
.
s
ummary
.
scalar
(
name
+
'-
mean'
,
tf
.
reduce_mean
(
var
))
return
if
action
==
'rms'
:
tf
.
s
calar_summary
(
name
+
'/
rms'
,
rms
(
var
))
tf
.
s
ummary
.
scalar
(
name
+
'-
rms'
,
rms
(
var
))
return
raise
RuntimeError
(
"Unknown summary type: {}"
.
format
(
action
))
params
=
tf
.
get_collection
(
tf
.
GraphKeys
.
TRAINABLE_VARIABLES
)
with
tf
.
name_scope
(
'param
_
summary'
):
with
tf
.
name_scope
(
'param
-
summary'
):
for
p
in
params
:
name
=
p
.
name
for
rgx
,
actions
in
summary_lists
:
...
...
@@ -111,7 +110,7 @@ def summary_moving_average(tensors=None):
"""
if
tensors
is
None
:
tensors
=
tf
.
get_collection
(
MOVING_SUMMARY_VARS_KEY
)
with
tf
.
name_scope
(
'EMA
_
summary'
):
with
tf
.
name_scope
(
'EMA
-
summary'
):
# TODO will produce EMA_summary/tower0/xxx. not elegant
with
tf
.
name_scope
(
None
):
averager
=
tf
.
train
.
ExponentialMovingAverage
(
...
...
@@ -119,6 +118,6 @@ def summary_moving_average(tensors=None):
avg_maintain_op
=
averager
.
apply
(
tensors
)
for
idx
,
c
in
enumerate
(
tensors
):
name
=
re
.
sub
(
'tower[p0-9]+/'
,
''
,
c
.
op
.
name
)
tf
.
s
calar_summary
(
name
,
averager
.
average
(
c
))
tf
.
s
ummary
.
scalar
(
name
,
averager
.
average
(
c
))
return
avg_maintain_op
tensorpack/tfutils/symbolic_functions.py
View file @
9fc5d856
...
...
@@ -116,5 +116,6 @@ def get_scalar_var(name, init_value, summary=False, trainable=False):
initializer
=
tf
.
constant_initializer
(
init_value
),
trainable
=
trainable
)
if
summary
:
tf
.
scalar_summary
(
name
,
ret
)
# this is recognized in callbacks.StatHolder
tf
.
summary
.
scalar
(
name
+
'-summary'
,
ret
)
return
ret
tensorpack/train/base.py
View file @
9fc5d856
...
...
@@ -109,8 +109,8 @@ class Trainer(object):
if
not
hasattr
(
logger
,
'LOG_DIR'
):
raise
RuntimeError
(
"logger directory wasn't set!"
)
self
.
summary_writer
=
tf
.
train
.
Summary
Writer
(
logger
.
LOG_DIR
,
graph
=
self
.
sess
.
graph
)
self
.
summary_op
=
tf
.
merge_all_summaries
()
self
.
summary_writer
=
tf
.
summary
.
File
Writer
(
logger
.
LOG_DIR
,
graph
=
self
.
sess
.
graph
)
self
.
summary_op
=
tf
.
summary
.
merge_all
()
# create an empty StatHolder
self
.
stat_holder
=
StatHolder
(
logger
.
LOG_DIR
)
...
...
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