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
51c58dfa
Commit
51c58dfa
authored
Feb 15, 2016
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
summary writer print all scalar by default
parent
e6a136ce
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
11 deletions
+11
-11
example_mnist.py
example_mnist.py
+1
-1
tensorpack/callbacks/common.py
tensorpack/callbacks/common.py
+9
-10
tensorpack/train.py
tensorpack/train.py
+1
-0
No files found.
example_mnist.py
View file @
51c58dfa
...
...
@@ -109,7 +109,7 @@ def get_config():
dataset
=
dataset_train
,
optimizer
=
tf
.
train
.
AdamOptimizer
(
lr
),
callbacks
=
Callbacks
([
SummaryWriter
(
print_tag
=
[
'train_cost'
,
'train_error'
]
),
SummaryWriter
(),
PeriodicSaver
(),
ValidationError
(
dataset_test
,
prefix
=
'validation'
),
]),
...
...
tensorpack/callbacks/common.py
View file @
51c58dfa
...
...
@@ -32,8 +32,9 @@ class PeriodicSaver(PeriodicCallback):
class
SummaryWriter
(
Callback
):
def
__init__
(
self
,
print_tag
=
None
):
""" if None, print all scalar summary"""
self
.
log_dir
=
logger
.
LOG_DIR
self
.
print_tag
=
print_tag
if
print_tag
else
[
'train_cost'
]
self
.
print_tag
=
print_tag
def
_before_train
(
self
):
self
.
writer
=
tf
.
train
.
SummaryWriter
(
...
...
@@ -44,22 +45,20 @@ class SummaryWriter(Callback):
def
_trigger_epoch
(
self
):
self
.
epoch_num
+=
1
# check if there is any summary
# check if there is any summary
to write
if
self
.
summary_op
is
None
:
return
summary_str
=
self
.
summary_op
.
eval
()
summary
=
tf
.
Summary
.
FromString
(
summary_str
)
printed_tag
=
set
()
for
val
in
summary
.
value
:
#print val.tag
val
.
tag
=
re
.
sub
(
'tower[0-9]*/'
,
''
,
val
.
tag
)
if
val
.
tag
in
self
.
print_tag
:
assert
val
.
WhichOneof
(
'value'
)
==
'simple_value'
,
\
'Cannot print summary {}: not a simple_value summary!'
.
format
(
val
.
tag
)
logger
.
info
(
'{}: {:.4f}'
.
format
(
val
.
tag
,
val
.
simple_value
))
printed_tag
.
add
(
val
.
tag
)
if
val
.
WhichOneof
(
'value'
)
==
'simple_value'
:
val
.
tag
=
re
.
sub
(
'tower[0-9]*/'
,
''
,
val
.
tag
)
if
self
.
print_tag
is
None
or
val
.
tag
in
self
.
print_tag
:
logger
.
info
(
'{}: {:.4f}'
.
format
(
val
.
tag
,
val
.
simple_value
))
printed_tag
.
add
(
val
.
tag
)
self
.
writer
.
add_summary
(
summary
,
get_global_step
())
if
self
.
epoch_num
==
1
:
if
self
.
print_tag
is
not
None
and
self
.
epoch_num
==
1
:
if
len
(
printed_tag
)
!=
len
(
self
.
print_tag
):
logger
.
warn
(
"Tags to print not found in Summary Writer: {}"
.
format
(
", "
.
join
([
k
for
k
in
self
.
print_tag
if
k
not
in
printed_tag
])))
...
...
tensorpack/train.py
View file @
51c58dfa
...
...
@@ -72,6 +72,7 @@ def average_grads(tower_grads):
def
summary_grads
(
grads
):
for
grad
,
var
in
grads
:
if
grad
:
# TODO also summary RMS and print
tf
.
histogram_summary
(
var
.
op
.
name
+
'/gradients'
,
grad
)
def
check_grads
(
grads
):
...
...
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