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
3b7e7c55
Commit
3b7e7c55
authored
Jul 29, 2017
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Call Trainer._setup() in constructor, to logically allow custom graph built outside trainer. (#318)
parent
ec1bea93
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
7 deletions
+10
-7
tensorpack/train/base.py
tensorpack/train/base.py
+10
-7
No files found.
tensorpack/train/base.py
View file @
3b7e7c55
...
...
@@ -64,6 +64,8 @@ class Trainer(object):
self
.
monitors
=
[]
self
.
_epoch_num
=
None
self
.
_setup
()
# subclass will setup the graph
@
property
def
epoch_num
(
self
):
if
self
.
_epoch_num
is
not
None
:
...
...
@@ -76,9 +78,6 @@ class Trainer(object):
"""
Use this method before :meth:`Trainer._setup` finishes,
to register a callback to the trainer.
The hooks of the registered callback will be bind to the
`self.hooked_sess` session.
"""
assert
isinstance
(
cb
,
Callback
),
cb
assert
not
isinstance
(
self
.
_callbacks
,
Callbacks
),
\
...
...
@@ -120,8 +119,6 @@ class Trainer(object):
"""
Setup the trainer and be ready for the main loop.
"""
self
.
_setup
()
# subclass will setup the graph
self
.
register_callback
(
MaintainStepCounter
())
for
cb
in
self
.
config
.
callbacks
:
self
.
register_callback
(
cb
)
...
...
@@ -160,9 +157,15 @@ class Trainer(object):
self
.
hooked_sess
=
tf
.
train
.
MonitoredSession
(
session_creator
=
ReuseSessionCreator
(
self
.
sess
),
hooks
=
hooks
)
@
abstractmethod
def
_setup
(
self
):
""" setup Trainer-specific stuff for training"""
"""
Build the entire graph for training.
Responsible for setup InputSource as well (including registering InputSource callbacks)
Since this method will get called in constructor only,
you can simply leave it empty and build your graph outside the trainer.
"""
pass
@
property
def
global_step
(
self
):
...
...
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