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
b4a5b6e9
Commit
b4a5b6e9
authored
May 14, 2016
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
proxy callback
parent
4aaf06ca
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
8 deletions
+17
-8
tensorpack/callbacks/base.py
tensorpack/callbacks/base.py
+17
-8
No files found.
tensorpack/callbacks/base.py
View file @
b4a5b6e9
...
...
@@ -87,8 +87,23 @@ class Callback(object):
def
_trigger_epoch
(
self
):
pass
class
ProxyCallback
(
Callback
):
def
__init__
(
self
,
cb
):
self
.
cb
=
cb
def
_before_train
(
self
):
self
.
cb
.
before_train
()
def
_setup_graph
(
self
):
self
.
cb
.
setup_graph
(
self
.
trainer
)
class
PeriodicCallback
(
Callback
):
def
_after_train
(
self
):
self
.
cb
.
after_train
()
def
_trigger_epoch
(
self
):
self
.
cb
.
trigger_epoch
()
class
PeriodicCallback
(
ProxyCallback
):
"""
A callback to be triggered after every `period` epochs.
Doesn't work for trigger_step
...
...
@@ -98,15 +113,9 @@ class PeriodicCallback(Callback):
:param cb: a `Callback`
:param period: int
"""
s
elf
.
cb
=
cb
s
uper
(
PeriodicCallback
,
self
)
.
__init__
(
self
,
cb
)
self
.
period
=
int
(
period
)
def
_before_train
(
self
):
self
.
cb
.
before_train
(
self
.
trainer
)
def
_after_train
(
self
):
self
.
cb
.
after_train
()
def
_trigger_epoch
(
self
):
self
.
cb
.
epoch_num
=
self
.
epoch_num
-
1
if
self
.
epoch_num
%
self
.
period
==
0
:
...
...
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