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
4126a583
Commit
4126a583
authored
Oct 17, 2017
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make _monitors private as well.
parent
e10d43e7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
5 deletions
+19
-5
tensorpack/train/base.py
tensorpack/train/base.py
+19
-5
No files found.
tensorpack/train/base.py
View file @
4126a583
...
@@ -11,6 +11,7 @@ import tensorflow as tf
...
@@ -11,6 +11,7 @@ import tensorflow as tf
from
.config
import
TrainConfig
from
.config
import
TrainConfig
from
..utils
import
logger
from
..utils
import
logger
from
..utils.develop
import
log_deprecated
from
..callbacks
import
Callback
,
Callbacks
from
..callbacks
import
Callback
,
Callbacks
from
..callbacks.monitor
import
Monitors
,
TrainingMonitor
from
..callbacks.monitor
import
Monitors
,
TrainingMonitor
from
..tfutils
import
get_global_step_value
from
..tfutils
import
get_global_step_value
...
@@ -116,7 +117,7 @@ class Trainer(object):
...
@@ -116,7 +117,7 @@ class Trainer(object):
self
.
model
=
config
.
model
self
.
model
=
config
.
model
self
.
_callbacks
=
[]
self
.
_callbacks
=
[]
self
.
monitors
=
[]
self
.
_
monitors
=
[]
self
.
loop
=
TrainLoop
()
self
.
loop
=
TrainLoop
()
self
.
loop
.
config
(
config
.
steps_per_epoch
,
config
.
starting_epoch
,
config
.
max_epoch
)
self
.
loop
.
config
(
config
.
steps_per_epoch
,
config
.
starting_epoch
,
config
.
max_epoch
)
...
@@ -141,14 +142,19 @@ class Trainer(object):
...
@@ -141,14 +142,19 @@ class Trainer(object):
It can only be called before :meth:`Trainer.train` gets called.
It can only be called before :meth:`Trainer.train` gets called.
"""
"""
assert
isinstance
(
mon
,
TrainingMonitor
),
mon
assert
isinstance
(
mon
,
TrainingMonitor
),
mon
assert
not
isinstance
(
self
.
monitors
,
Monitors
),
\
assert
not
isinstance
(
self
.
_
monitors
,
Monitors
),
\
"Cannot register more monitors after trainer was setup!"
"Cannot register more monitors after trainer was setup!"
if
not
self
.
is_chief
and
mon
.
chief_only
:
if
not
self
.
is_chief
and
mon
.
chief_only
:
logger
.
warn
(
"Monitor {} is chief-only, skipped."
.
format
(
str
(
mon
)))
logger
.
warn
(
"Monitor {} is chief-only, skipped."
.
format
(
str
(
mon
)))
else
:
else
:
self
.
monitors
.
append
(
mon
)
self
.
_
monitors
.
append
(
mon
)
self
.
register_callback
(
mon
)
self
.
register_callback
(
mon
)
@
property
def
monitors
(
self
):
assert
isinstance
(
self
.
_monitors
,
Monitors
),
"Monitors haven't been setup!"
return
self
.
_monitors
def
train
(
self
):
def
train
(
self
):
""" Start training """
""" Start training """
self
.
setup
()
self
.
setup
()
...
@@ -177,8 +183,8 @@ class Trainer(object):
...
@@ -177,8 +183,8 @@ class Trainer(object):
self
.
register_callback
(
cb
)
self
.
register_callback
(
cb
)
for
m
in
self
.
_config
.
monitors
:
for
m
in
self
.
_config
.
monitors
:
self
.
register_monitor
(
m
)
self
.
register_monitor
(
m
)
self
.
monitors
=
Monitors
(
self
.
monitors
)
self
.
_monitors
=
Monitors
(
self
.
_
monitors
)
self
.
register_callback
(
self
.
monitors
)
self
.
register_callback
(
self
.
_
monitors
)
describe_trainable_vars
()
describe_trainable_vars
()
...
@@ -287,6 +293,14 @@ class Trainer(object):
...
@@ -287,6 +293,14 @@ class Trainer(object):
# for internal use only. Should let graphbuilder return it.
# for internal use only. Should let graphbuilder return it.
return
""
return
""
@
property
def
config
(
self
):
log_deprecated
(
"Trainer.config"
,
"It is supposed to be private! Most of its attributes can be accessed by other means."
,
"2017-12-31"
)
return
self
.
_config
def
_get_property
(
name
):
def
_get_property
(
name
):
"""
"""
...
...
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