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
3db6ccac
Commit
3db6ccac
authored
Oct 17, 2017
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
RunOp accepts either Op or lambda
parent
8e2428d9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
3 deletions
+6
-3
tensorpack/callbacks/graph.py
tensorpack/callbacks/graph.py
+6
-3
No files found.
tensorpack/callbacks/graph.py
View file @
3db6ccac
...
@@ -20,12 +20,13 @@ __all__ = ['RunOp', 'RunUpdateOps', 'ProcessTensors', 'DumpTensors', 'DumpTensor
...
@@ -20,12 +20,13 @@ __all__ = ['RunOp', 'RunUpdateOps', 'ProcessTensors', 'DumpTensors', 'DumpTensor
class
RunOp
(
Callback
):
class
RunOp
(
Callback
):
""" Run an Op. """
""" Run an Op. """
def
__init__
(
self
,
setup_func
,
def
__init__
(
self
,
op
,
run_before
=
True
,
run_as_trigger
=
True
,
run_before
=
True
,
run_as_trigger
=
True
,
run_step
=
False
,
verbose
=
False
):
run_step
=
False
,
verbose
=
False
):
"""
"""
Args:
Args:
setup_func: a function that returns the Op in the graph
op (tf.Operation or function): an Op, or a function that returns the Op in the graph.
The function will be called later (in the `setup_graph` callback).
run_before (bool): run the Op before training
run_before (bool): run the Op before training
run_as_trigger (bool): run the Op on every trigger
run_as_trigger (bool): run the Op on every trigger
run_step (bool): run the Op every step (along with training)
run_step (bool): run the Op every step (along with training)
...
@@ -36,7 +37,9 @@ class RunOp(Callback):
...
@@ -36,7 +37,9 @@ class RunOp(Callback):
<https://github.com/ppwwyyxx/tensorpack/blob/master/examples/DeepQNetwork/>`_
<https://github.com/ppwwyyxx/tensorpack/blob/master/examples/DeepQNetwork/>`_
uses this callback to update target network.
uses this callback to update target network.
"""
"""
self
.
setup_func
=
setup_func
if
not
callable
(
op
):
op
=
lambda
:
op
# noqa
self
.
setup_func
=
op
self
.
run_before
=
run_before
self
.
run_before
=
run_before
self
.
run_as_trigger
=
run_as_trigger
self
.
run_as_trigger
=
run_as_trigger
self
.
run_step
=
run_step
self
.
run_step
=
run_step
...
...
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