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
dc41c5ce
Commit
dc41c5ce
authored
Aug 27, 2018
by
Michael Carilli
Browse files
Adjusting learning rate for batch size
parent
437bcf22
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
4 additions
and
3 deletions
+4
-3
examples/imagenet/README.md
examples/imagenet/README.md
+0
-3
examples/imagenet/main.py
examples/imagenet/main.py
+2
-0
examples/imagenet/main_fp16_optimizer.py
examples/imagenet/main_fp16_optimizer.py
+2
-0
No files found.
examples/imagenet/README.md
View file @
dc41c5ce
...
@@ -64,9 +64,6 @@ $ python -m torch.distributed.launch --nproc_per_node=NUM_GPUS main_fp16_optimiz
...
@@ -64,9 +64,6 @@ $ python -m torch.distributed.launch --nproc_per_node=NUM_GPUS main_fp16_optimiz
## Usage for `main.py` and `main_fp16_optimizer.py`
## Usage for `main.py` and `main_fp16_optimizer.py`
```
bash
```
`main_fp16_optimizer.py`
also accepts the optional flag
`main_fp16_optimizer.py`
also accepts the optional flag
```
bash
```
bash
--dynamic-loss-scale
Use dynamic loss scaling. If supplied, this argument
--dynamic-loss-scale
Use dynamic loss scaling. If supplied, this argument
...
...
examples/imagenet/main.py
View file @
dc41c5ce
...
@@ -133,6 +133,8 @@ def main():
...
@@ -133,6 +133,8 @@ def main():
# define loss function (criterion) and optimizer
# define loss function (criterion) and optimizer
criterion
=
nn
.
CrossEntropyLoss
().
cuda
()
criterion
=
nn
.
CrossEntropyLoss
().
cuda
()
# Scale learning rate based on per-process batch size
args
.
lr
=
args
.
lr
*
float
(
args
.
batch_size
)
/
256.
optimizer
=
torch
.
optim
.
SGD
(
master_params
,
args
.
lr
,
optimizer
=
torch
.
optim
.
SGD
(
master_params
,
args
.
lr
,
momentum
=
args
.
momentum
,
momentum
=
args
.
momentum
,
weight_decay
=
args
.
weight_decay
)
weight_decay
=
args
.
weight_decay
)
...
...
examples/imagenet/main_fp16_optimizer.py
View file @
dc41c5ce
...
@@ -134,6 +134,8 @@ def main():
...
@@ -134,6 +134,8 @@ def main():
# define loss function (criterion) and optimizer
# define loss function (criterion) and optimizer
criterion
=
nn
.
CrossEntropyLoss
().
cuda
()
criterion
=
nn
.
CrossEntropyLoss
().
cuda
()
# Scale learning rate based on per-process batch size
args
.
lr
=
args
.
lr
*
float
(
args
.
batch_size
)
/
256.
optimizer
=
torch
.
optim
.
SGD
(
model
.
parameters
(),
args
.
lr
,
optimizer
=
torch
.
optim
.
SGD
(
model
.
parameters
(),
args
.
lr
,
momentum
=
args
.
momentum
,
momentum
=
args
.
momentum
,
weight_decay
=
args
.
weight_decay
)
weight_decay
=
args
.
weight_decay
)
...
...
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