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
40c3ab6a
Commit
40c3ab6a
authored
Jun 25, 2019
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
AccumGrad supports sparse update (fix #435)
parent
e0391e29
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
6 deletions
+3
-6
tensorpack/tfutils/optimizer.py
tensorpack/tfutils/optimizer.py
+3
-6
No files found.
tensorpack/tfutils/optimizer.py
View file @
40c3ab6a
...
@@ -145,9 +145,6 @@ class AccumGradOptimizer(ProxyOptimizer):
...
@@ -145,9 +145,6 @@ class AccumGradOptimizer(ProxyOptimizer):
This is roughly the same as using a :math:`k` times larger batch size plus a
This is roughly the same as using a :math:`k` times larger batch size plus a
:math:`k` times larger learning rate, but uses much less memory.
:math:`k` times larger learning rate, but uses much less memory.
Note that this implementation may not support all models.
E.g., it currently doesn't support sparse gradient update.
This optimizer can be used in any TensorFlow code (with or without tensorpack).
This optimizer can be used in any TensorFlow code (with or without tensorpack).
Example:
Example:
...
@@ -183,9 +180,9 @@ class AccumGradOptimizer(ProxyOptimizer):
...
@@ -183,9 +180,9 @@ class AccumGradOptimizer(ProxyOptimizer):
grads_and_vars
=
FilterNoneGrad
()
.
process
(
grads_and_vars
)
grads_and_vars
=
FilterNoneGrad
()
.
process
(
grads_and_vars
)
vs
=
[]
vs
=
[]
for
g
,
v
in
grads_and_vars
:
for
g
,
v
in
grads_and_vars
:
assert
isinstance
(
g
,
tf
.
Tensor
)
and
isinstance
(
v
,
tf
.
Variable
),
\
assert
isinstance
(
g
,
(
tf
.
Tensor
,
tf
.
IndexedSlices
)
)
and
isinstance
(
v
,
tf
.
Variable
),
\
"AccumGradOptimizer
only works for dense update
! "
\
"AccumGradOptimizer
does not work for the gradient of {}
! "
\
"Types of v and g are {} and {}"
.
format
(
type
(
v
),
type
(
g
))
"Types of v and g are {} and {}"
.
format
(
v
.
op
.
name
,
type
(
v
),
type
(
g
))
vs
.
append
(
v
)
vs
.
append
(
v
)
with
tf
.
control_dependencies
(
None
):
with
tf
.
control_dependencies
(
None
):
...
...
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