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
563b9cd6
Commit
563b9cd6
authored
Jan 10, 2017
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CallbackFactory. fix style. add travis email
parent
93908ddc
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
15 deletions
+52
-15
.travis.yml
.travis.yml
+5
-1
examples/ConvolutionalPoseMachines/load-cpm.py
examples/ConvolutionalPoseMachines/load-cpm.py
+1
-0
tensorpack/callbacks/base.py
tensorpack/callbacks/base.py
+46
-14
No files found.
.travis.yml
View file @
563b9cd6
...
...
@@ -16,4 +16,8 @@ script:
-
cd examples && flake8 .
notifications
:
email
:
false
email
:
recipients
:
-
ppwwyyxxc@gmail.com
on_success
:
never
on_failure
:
change
# default: always
examples/ConvolutionalPoseMachines/load-cpm.py
View file @
563b9cd6
...
...
@@ -24,6 +24,7 @@ _CM = plt.get_cmap('jet')
14: background
"""
def
colorize
(
img
,
heatmap
):
""" img: bgr, [0,255]
heatmap: [0,1]
...
...
tensorpack/callbacks/base.py
View file @
563b9cd6
...
...
@@ -6,22 +6,13 @@ import tensorflow as tf
from
abc
import
ABCMeta
import
six
__all__
=
[
'Callback'
,
'PeriodicCallback'
,
'ProxyCallback'
]
__all__
=
[
'Callback'
,
'PeriodicCallback'
,
'ProxyCallback'
,
'CallbackFactory'
]
@
six
.
add_metaclass
(
ABCMeta
)
class
Callback
(
object
):
""" Base class for all callbacks """
def
before_train
(
self
):
"""
Called right before the first iteration.
"""
self
.
_before_train
()
def
_before_train
(
self
):
pass
def
setup_graph
(
self
,
trainer
):
"""
Called before finalizing the graph.
...
...
@@ -40,13 +31,13 @@ class Callback(object):
def
_setup_graph
(
self
):
pass
def
after
_train
(
self
):
def
before
_train
(
self
):
"""
Called
after training
.
Called
right before the first iteration
.
"""
self
.
_
after
_train
()
self
.
_
before
_train
()
def
_
after
_train
(
self
):
def
_
before
_train
(
self
):
pass
def
trigger_step
(
self
):
...
...
@@ -68,6 +59,15 @@ class Callback(object):
def
_trigger_epoch
(
self
):
pass
def
after_train
(
self
):
"""
Called after training.
"""
self
.
_after_train
()
def
_after_train
(
self
):
pass
def
__str__
(
self
):
return
type
(
self
)
.
__name__
...
...
@@ -127,3 +127,35 @@ class PeriodicCallback(ProxyCallback):
def
__str__
(
self
):
return
"Periodic-"
+
str
(
self
.
cb
)
class
CallbackFactory
(
Callback
):
"""
Create a callback with some lambdas.
"""
def
__init__
(
self
,
setup_graph
=
None
,
before_train
=
None
,
trigger_epoch
=
None
,
after_train
=
None
):
"""
Each lambda takes ``self`` as the only argument.
"""
self
.
_cb_setup_graph
=
setup_graph
self
.
_cb_before_train
=
before_train
self
.
_cb_trigger_epoch
=
trigger_epoch
self
.
_cb_after_train
=
after_train
def
_setup_graph
(
self
):
if
self
.
_cb_setup_graph
:
self
.
_cb_setup_graph
(
self
)
def
_before_train
(
self
):
if
self
.
_cb_before_train
:
self
.
_cb_before_train
(
self
)
def
_trigger_epoch
(
self
):
if
self
.
_cb_trigger_epoch
:
self
.
_cb_trigger_epoch
(
self
)
def
_after_train
(
self
):
if
self
.
_cb_after_train
:
self
.
_cb_after_train
(
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