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
728eb800
Commit
728eb800
authored
Dec 22, 2017
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow some gradient options to be settable (#568, #427)
parent
a3cc3a18
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
1 deletion
+15
-1
tensorpack/train/tower.py
tensorpack/train/tower.py
+15
-1
No files found.
tensorpack/train/tower.py
View file @
728eb800
...
...
@@ -122,6 +122,18 @@ class SingleCostTrainer(TowerTrainer):
To use a :class:`SingleCostTrainer` object, call `trainer.setup_graph(...); trainer.train(...)`.
"""
COLOCATE_GRADIENTS_WITH_OPS
=
True
"""
See `tf.gradients`. This might affect performance when backward op does
not support the device of forward op.
"""
GATE_GRADIENTS
=
False
"""See `tf.gradients`. """
AGGREGATION_METHOD
=
tf
.
AggregationMethod
.
DEFAULT
"""See `tf.gradients`. """
@
call_only_once
def
setup_graph
(
self
,
inputs_desc
,
input
,
get_cost_fn
,
get_opt_fn
):
"""
...
...
@@ -182,7 +194,9 @@ class SingleCostTrainer(TowerTrainer):
opt
=
get_opt_fn
()
grads
=
opt
.
compute_gradients
(
cost
,
var_list
=
varlist
,
gate_gradients
=
False
,
colocate_gradients_with_ops
=
True
)
gate_gradients
=
self
.
GATE_GRADIENTS
,
colocate_gradients_with_ops
=
self
.
COLOCATE_GRADIENTS_WITH_OPS
,
aggregation_method
=
self
.
AGGREGATION_METHOD
)
grads
=
FilterNoneGrad
()
.
process
(
grads
)
return
grads
...
...
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