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
6ca57de4
Commit
6ca57de4
authored
Jan 30, 2018
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bug in PeriodicRunHooks
parent
4eb2be09
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
4 deletions
+10
-4
tensorpack/callbacks/trigger.py
tensorpack/callbacks/trigger.py
+10
-4
No files found.
tensorpack/callbacks/trigger.py
View file @
6ca57de4
...
@@ -63,10 +63,13 @@ class PeriodicRunHooks(ProxyCallback):
...
@@ -63,10 +63,13 @@ class PeriodicRunHooks(ProxyCallback):
def
_before_run
(
self
,
ctx
):
def
_before_run
(
self
,
ctx
):
if
self
.
global_step
%
self
.
_every_k_steps
==
0
:
if
self
.
global_step
%
self
.
_every_k_steps
==
0
:
self
.
_enabled
=
True
return
self
.
cb
.
_before_run
(
ctx
)
return
self
.
cb
.
_before_run
(
ctx
)
else
:
self
.
_enabled
=
False
def
_after_run
(
self
,
ctx
,
rv
):
def
_after_run
(
self
,
ctx
,
rv
):
if
self
.
global_step
%
self
.
_every_k_steps
==
0
:
if
self
.
_enabled
:
self
.
cb
.
_after_run
(
ctx
,
rv
)
self
.
cb
.
_after_run
(
ctx
,
rv
)
def
__str__
(
self
):
def
__str__
(
self
):
...
@@ -80,8 +83,8 @@ class EnableCallbackIf(ProxyCallback):
...
@@ -80,8 +83,8 @@ class EnableCallbackIf(ProxyCallback):
The other methods will be called the same.
The other methods will be called the same.
Note:
Note:
If you
need to use ``{before,after}_run``, make sure
If you
use ``{before,after}_run``,
that ``pred`` will eval to the same results in both methods every step
.
``pred`` will be evaluated only in ``before_run``
.
"""
"""
def
__init__
(
self
,
callback
,
pred
):
def
__init__
(
self
,
callback
,
pred
):
"""
"""
...
@@ -94,10 +97,13 @@ class EnableCallbackIf(ProxyCallback):
...
@@ -94,10 +97,13 @@ class EnableCallbackIf(ProxyCallback):
def
_before_run
(
self
,
ctx
):
def
_before_run
(
self
,
ctx
):
if
self
.
_pred
(
self
):
if
self
.
_pred
(
self
):
self
.
_enabled
=
True
return
super
(
EnableCallbackIf
,
self
)
.
_before_run
(
ctx
)
return
super
(
EnableCallbackIf
,
self
)
.
_before_run
(
ctx
)
else
:
self
.
_enabled
=
False
def
_after_run
(
self
,
ctx
,
rv
):
def
_after_run
(
self
,
ctx
,
rv
):
if
self
.
_
pred
(
self
)
:
if
self
.
_
enabled
:
super
(
EnableCallbackIf
,
self
)
.
_after_run
(
ctx
,
rv
)
super
(
EnableCallbackIf
,
self
)
.
_after_run
(
ctx
,
rv
)
def
_before_epoch
(
self
):
def
_before_epoch
(
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