Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
apex
Commits
c8d7c9f1
"vscode:/vscode.git/clone" did not exist on "ff01be0fac48e08878be60ff51610f24d39b86c8"
Commit
c8d7c9f1
authored
Jan 28, 2019
by
jiej
Browse files
adding comment to explain single process gradient averaging
parent
63e47d29
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
0 deletions
+2
-0
tests/synced_batchnorm/two_gpu_unit_test.py
tests/synced_batchnorm/two_gpu_unit_test.py
+2
-0
No files found.
tests/synced_batchnorm/two_gpu_unit_test.py
View file @
c8d7c9f1
...
@@ -92,6 +92,8 @@ inp_bn = inp_t.clone().requires_grad_()
...
@@ -92,6 +92,8 @@ inp_bn = inp_t.clone().requires_grad_()
grad_bn
=
grad_output_t
.
clone
().
detach
()
grad_bn
=
grad_output_t
.
clone
().
detach
()
out_bn
=
bn
(
inp_bn
)
out_bn
=
bn
(
inp_bn
)
out_bn
.
backward
(
grad_bn
)
out_bn
.
backward
(
grad_bn
)
# compensating the averaging over processes done by DDP
# in order to produce mathmetically equivalent result
for
param
in
bn
.
parameters
():
for
param
in
bn
.
parameters
():
param
.
grad
=
param
.
grad
/
args
.
world_size
param
.
grad
=
param
.
grad
/
args
.
world_size
bn_opt
=
optim
.
SGD
(
bn
.
parameters
(),
lr
=
1.0
)
bn_opt
=
optim
.
SGD
(
bn
.
parameters
(),
lr
=
1.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