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
9b3b5413
Commit
9b3b5413
authored
Jul 06, 2019
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Speed up TFEventWriter initialization
parent
dd138d5a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
10 deletions
+18
-10
tensorpack/callbacks/group.py
tensorpack/callbacks/group.py
+3
-1
tensorpack/callbacks/monitor.py
tensorpack/callbacks/monitor.py
+15
-9
No files found.
tensorpack/callbacks/group.py
View file @
9b3b5413
...
@@ -51,7 +51,9 @@ class CallbackTimeLogger(object):
...
@@ -51,7 +51,9 @@ class CallbackTimeLogger(object):
class
Callbacks
(
Callback
):
class
Callbacks
(
Callback
):
"""
"""
A container to hold all callbacks, and trigger them iteratively.
A container to hold all callbacks, and trigger them iteratively.
Note that it does nothing to before_run/after_run.
This is only used by the base trainer to run all the callbacks.
Users do not need to use this class.
"""
"""
def
__init__
(
self
,
cbs
):
def
__init__
(
self
,
cbs
):
...
...
tensorpack/callbacks/monitor.py
View file @
9b3b5413
...
@@ -12,6 +12,7 @@ import time
...
@@ -12,6 +12,7 @@ import time
from
collections
import
defaultdict
from
collections
import
defaultdict
from
datetime
import
datetime
from
datetime
import
datetime
import
six
import
six
import
threading
from
..compat
import
tfv1
as
tf
from
..compat
import
tfv1
as
tf
from
..libinfo
import
__git_version__
from
..libinfo
import
__git_version__
...
@@ -23,7 +24,7 @@ from .base import Callback
...
@@ -23,7 +24,7 @@ from .base import Callback
__all__
=
[
'MonitorBase'
,
'Monitors'
,
__all__
=
[
'MonitorBase'
,
'Monitors'
,
'TFEventWriter'
,
'JSONWriter'
,
'TFEventWriter'
,
'JSONWriter'
,
'ScalarPrinter'
,
'SendMonitorData'
,
'ScalarPrinter'
,
'SendMonitorData'
,
'
TrainingMonitor'
,
'
CometMLMonitor'
]
'CometMLMonitor'
]
def
image_to_nhwc
(
arr
):
def
image_to_nhwc
(
arr
):
...
@@ -53,7 +54,9 @@ class MonitorBase(Callback):
...
@@ -53,7 +54,9 @@ class MonitorBase(Callback):
_chief_only
=
False
_chief_only
=
False
def
setup_graph
(
self
,
trainer
):
def
setup_graph
(
self
,
trainer
):
# Set attributes following Callback.setup_graph
self
.
trainer
=
trainer
self
.
trainer
=
trainer
self
.
graph
=
tf
.
get_default_graph
()
self
.
_setup_graph
()
self
.
_setup_graph
()
def
_setup_graph
(
self
):
def
_setup_graph
(
self
):
...
@@ -97,12 +100,6 @@ class MonitorBase(Callback):
...
@@ -97,12 +100,6 @@ class MonitorBase(Callback):
# TODO process other types
# TODO process other types
TrainingMonitor
=
MonitorBase
"""
Old name
"""
class
NoOpMonitor
(
MonitorBase
):
class
NoOpMonitor
(
MonitorBase
):
def
__init__
(
self
,
name
=
None
):
def
__init__
(
self
,
name
=
None
):
self
.
_name
=
name
self
.
_name
=
name
...
@@ -259,8 +256,17 @@ class TFEventWriter(MonitorBase):
...
@@ -259,8 +256,17 @@ class TFEventWriter(MonitorBase):
def
_setup_graph
(
self
):
def
_setup_graph
(
self
):
self
.
_writer
=
tf
.
summary
.
FileWriter
(
self
.
_writer
=
tf
.
summary
.
FileWriter
(
self
.
_logdir
,
graph
=
tf
.
get_default_graph
(),
self
.
_logdir
,
max_queue
=
self
.
_max_queue
,
flush_secs
=
self
.
_flush_secs
)
max_queue
=
self
.
_max_queue
,
flush_secs
=
self
.
_flush_secs
)
def
_write_graph
(
self
):
self
.
_writer
.
add_graph
(
self
.
graph
)
def
_before_train
(
self
):
# Writing the graph is expensive (takes ~2min) when the graph is large.
# Therefore use a separate thread. It will then run in the
# background while TF is warming up in the first several iterations.
self
.
_write_graph_thread
=
threading
.
Thread
(
target
=
self
.
_write_graph
,
daemon
=
True
)
self
.
_write_graph_thread
.
start
()
@
HIDE_DOC
@
HIDE_DOC
def
process_summary
(
self
,
summary
):
def
process_summary
(
self
,
summary
):
...
...
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