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
17971202
"...git@developer.sourcefind.cn:OpenDAS/megatron-lm.git" did not exist on "688448db7547be90203440cfd105703d8a853f39"
Commit
17971202
authored
Aug 18, 2018
by
Michael Carilli
Browse files
updating FP16_Optimizer example as well
parent
eae8b989
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
4 deletions
+18
-4
examples/imagenet/main_fp16_optimizer.py
examples/imagenet/main_fp16_optimizer.py
+18
-4
No files found.
examples/imagenet/main_fp16_optimizer.py
View file @
17971202
...
...
@@ -204,7 +204,6 @@ def main():
for
epoch
in
range
(
args
.
start_epoch
,
args
.
epochs
):
if
args
.
distributed
:
train_sampler
.
set_epoch
(
epoch
)
adjust_learning_rate
(
optimizer
,
epoch
)
# train for one epoch
train
(
train_loader
,
model
,
criterion
,
optimizer
,
epoch
)
...
...
@@ -277,6 +276,8 @@ def train(train_loader, model, criterion, optimizer, epoch):
while
input
is
not
None
:
i
+=
1
adjust_learning_rate
(
optimizer
,
epoch
,
i
,
len
(
train_loader
))
if
args
.
prof
:
if
i
>
10
:
break
...
...
@@ -423,9 +424,22 @@ class AverageMeter(object):
self
.
avg
=
self
.
sum
/
self
.
count
def
adjust_learning_rate
(
optimizer
,
epoch
):
"""Sets the learning rate to the initial LR decayed by 10 every 30 epochs"""
lr
=
args
.
lr
*
(
0.1
**
(
epoch
//
30
))
def
adjust_learning_rate
(
optimizer
,
epoch
,
step
,
len_epoch
):
"""LR schedule that should yield 76% converged accuracy with batch size 256"""
factor
=
epoch
//
30
if
epoch
>=
80
:
factor
=
factor
+
1
lr
=
args
.
lr
*
(
0.1
**
factor
)
"""Warmup"""
if
epoch
<
5
:
lr
=
lr
*
float
(
step
+
epoch
*
len_epoch
)
/
(
5.
*
len_epoch
)
if
(
args
.
local_rank
==
0
):
print
(
"epoch = {}, step = {}, lr = {}"
.
format
(
epoch
,
step
,
lr
))
for
param_group
in
optimizer
.
param_groups
:
param_group
[
'lr'
]
=
lr
...
...
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