Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add missing world size for lr linear scale in main_multi_gpu #144

Merged
merged 1 commit into from
Dec 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions image_classification/BoTNet/main_multi_gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,11 +361,11 @@ def main_worker(*args):
# set lr according to batch size and world size (hacked from Swin official code and modified for CSwin)
if config.TRAIN.LINEAR_SCALED_LR is not None:
linear_scaled_lr = (
config.TRAIN.BASE_LR * config.DATA.BATCH_SIZE) / config.TRAIN.LINEAR_SCALED_LR
config.TRAIN.BASE_LR * config.DATA.BATCH_SIZE * world_size) / config.TRAIN.LINEAR_SCALED_LR
linear_scaled_warmup_start_lr = (
config.TRAIN.WARMUP_START_LR * config.DATA.BATCH_SIZE) / config.TRAIN.LINEAR_SCALED_LR
config.TRAIN.WARMUP_START_LR * config.DATA.BATCH_SIZE * world_size) / config.TRAIN.LINEAR_SCALED_LR
linear_scaled_end_lr = (
config.TRAIN.END_LR * config.DATA.BATCH_SIZE) / config.TRAIN.LINEAR_SCALED_LR
config.TRAIN.END_LR * config.DATA.BATCH_SIZE * world_size) / config.TRAIN.LINEAR_SCALED_LR

if config.TRAIN.ACCUM_ITER > 1:
linear_scaled_lr = linear_scaled_lr * config.TRAIN.ACCUM_ITER
Expand Down
6 changes: 3 additions & 3 deletions image_classification/CSwin/main_multi_gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,9 @@ def main_worker(*args):

# STEP 5: Define optimizer and lr_scheduler
# set lr according to batch size and world size (hacked from Swin official code and modified for CSwin)
linear_scaled_lr = (config.TRAIN.BASE_LR * config.DATA.BATCH_SIZE) / 256.0
linear_scaled_warmup_start_lr = (config.TRAIN.WARMUP_START_LR * config.DATA.BATCH_SIZE) / 256.0
linear_scaled_end_lr = (config.TRAIN.END_LR * config.DATA.BATCH_SIZE) / 256.0
linear_scaled_lr = (config.TRAIN.BASE_LR * config.DATA.BATCH_SIZE * world_size) / 256.0
linear_scaled_warmup_start_lr = (config.TRAIN.WARMUP_START_LR * config.DATA.BATCH_SIZE * world_size) / 256.0
linear_scaled_end_lr = (config.TRAIN.END_LR * config.DATA.BATCH_SIZE * world_size) / 256.0

if config.TRAIN.ACCUM_ITER > 1:
linear_scaled_lr = linear_scaled_lr * config.TRAIN.ACCUM_ITER
Expand Down
6 changes: 3 additions & 3 deletions image_classification/ConvMLP/main_multi_gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,11 +369,11 @@ def main_worker(*args):
# set lr according to batch size and world size (hacked from Swin official code and modified for CSwin)
if config.TRAIN.LINEAR_SCALED_LR is not None:
linear_scaled_lr = (
config.TRAIN.BASE_LR * config.DATA.BATCH_SIZE) / config.TRAIN.LINEAR_SCALED_LR
config.TRAIN.BASE_LR * config.DATA.BATCH_SIZE * world_size) / config.TRAIN.LINEAR_SCALED_LR
linear_scaled_warmup_start_lr = (
config.TRAIN.WARMUP_START_LR * config.DATA.BATCH_SIZE) / config.TRAIN.LINEAR_SCALED_LR
config.TRAIN.WARMUP_START_LR * config.DATA.BATCH_SIZE * world_size) / config.TRAIN.LINEAR_SCALED_LR
linear_scaled_end_lr = (
config.TRAIN.END_LR * config.DATA.BATCH_SIZE) / config.TRAIN.LINEAR_SCALED_LR
config.TRAIN.END_LR * config.DATA.BATCH_SIZE * world_size) / config.TRAIN.LINEAR_SCALED_LR

if config.TRAIN.ACCUM_ITER > 1:
linear_scaled_lr = linear_scaled_lr * config.TRAIN.ACCUM_ITER
Expand Down
6 changes: 3 additions & 3 deletions image_classification/ConvMixer/main_multi_gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,11 +360,11 @@ def main_worker(*args):
# set lr according to batch size and world size (hacked from Swin official code and modified for CSwin)
if config.TRAIN.LINEAR_SCALED_LR is not None:
linear_scaled_lr = (
config.TRAIN.BASE_LR * config.DATA.BATCH_SIZE) / config.TRAIN.LINEAR_SCALED_LR
config.TRAIN.BASE_LR * config.DATA.BATCH_SIZE * world_size) / config.TRAIN.LINEAR_SCALED_LR
linear_scaled_warmup_start_lr = (
config.TRAIN.WARMUP_START_LR * config.DATA.BATCH_SIZE) / config.TRAIN.LINEAR_SCALED_LR
config.TRAIN.WARMUP_START_LR * config.DATA.BATCH_SIZE * world_size) / config.TRAIN.LINEAR_SCALED_LR
linear_scaled_end_lr = (
config.TRAIN.END_LR * config.DATA.BATCH_SIZE) / config.TRAIN.LINEAR_SCALED_LR
config.TRAIN.END_LR * config.DATA.BATCH_SIZE * world_size) / config.TRAIN.LINEAR_SCALED_LR

if config.TRAIN.ACCUM_ITER > 1:
linear_scaled_lr = linear_scaled_lr * config.TRAIN.ACCUM_ITER
Expand Down
6 changes: 3 additions & 3 deletions image_classification/Cvt/main_multi_gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,11 +355,11 @@ def main_worker(*args):
# set lr according to batch size and world size (hacked from Swin official code and modified for CSwin)
if config.TRAIN.LINEAR_SCALED_LR is not None:
linear_scaled_lr = (
config.TRAIN.BASE_LR * config.DATA.BATCH_SIZE) / config.TRAIN.LINEAR_SCALED_LR
config.TRAIN.BASE_LR * config.DATA.BATCH_SIZE * world_size) / config.TRAIN.LINEAR_SCALED_LR
linear_scaled_warmup_start_lr = (
config.TRAIN.WARMUP_START_LR * config.DATA.BATCH_SIZE) / config.TRAIN.LINEAR_SCALED_LR
config.TRAIN.WARMUP_START_LR * config.DATA.BATCH_SIZE * world_size) / config.TRAIN.LINEAR_SCALED_LR
linear_scaled_end_lr = (
config.TRAIN.END_LR * config.DATA.BATCH_SIZE) / config.TRAIN.LINEAR_SCALED_LR
config.TRAIN.END_LR * config.DATA.BATCH_SIZE * world_size) / config.TRAIN.LINEAR_SCALED_LR

if config.TRAIN.ACCUM_ITER > 1:
linear_scaled_lr = linear_scaled_lr * config.TRAIN.ACCUM_ITER
Expand Down
6 changes: 3 additions & 3 deletions image_classification/DeiT/main_multi_gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,11 +395,11 @@ def main_worker(*args):
# set lr according to batch size and world size (hacked from Swin official code and modified for CSwin)
if config.TRAIN.LINEAR_SCALED_LR is not None:
linear_scaled_lr = (
config.TRAIN.BASE_LR * config.DATA.BATCH_SIZE) / config.TRAIN.LINEAR_SCALED_LR
config.TRAIN.BASE_LR * config.DATA.BATCH_SIZE * world_size) / config.TRAIN.LINEAR_SCALED_LR
linear_scaled_warmup_start_lr = (
config.TRAIN.WARMUP_START_LR * config.DATA.BATCH_SIZE) / config.TRAIN.LINEAR_SCALED_LR
config.TRAIN.WARMUP_START_LR * config.DATA.BATCH_SIZE * world_size) / config.TRAIN.LINEAR_SCALED_LR
linear_scaled_end_lr = (
config.TRAIN.END_LR * config.DATA.BATCH_SIZE) / config.TRAIN.LINEAR_SCALED_LR
config.TRAIN.END_LR * config.DATA.BATCH_SIZE * world_size) / config.TRAIN.LINEAR_SCALED_LR

if config.TRAIN.ACCUM_ITER > 1:
linear_scaled_lr = linear_scaled_lr * config.TRAIN.ACCUM_ITER
Expand Down
6 changes: 3 additions & 3 deletions image_classification/HaloNet/main_multi_gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,11 +359,11 @@ def main_worker(*args):
# set lr according to batch size and world size (hacked from Swin official code and modified for CSwin)
if config.TRAIN.LINEAR_SCALED_LR is not None:
linear_scaled_lr = (
config.TRAIN.BASE_LR * config.DATA.BATCH_SIZE) / config.TRAIN.LINEAR_SCALED_LR
config.TRAIN.BASE_LR * config.DATA.BATCH_SIZE * world_size) / config.TRAIN.LINEAR_SCALED_LR
linear_scaled_warmup_start_lr = (
config.TRAIN.WARMUP_START_LR * config.DATA.BATCH_SIZE) / config.TRAIN.LINEAR_SCALED_LR
config.TRAIN.WARMUP_START_LR * config.DATA.BATCH_SIZE * world_size) / config.TRAIN.LINEAR_SCALED_LR
linear_scaled_end_lr = (
config.TRAIN.END_LR * config.DATA.BATCH_SIZE) / config.TRAIN.LINEAR_SCALED_LR
config.TRAIN.END_LR * config.DATA.BATCH_SIZE * world_size) / config.TRAIN.LINEAR_SCALED_LR

if config.TRAIN.ACCUM_ITER > 1:
linear_scaled_lr = linear_scaled_lr * config.TRAIN.ACCUM_ITER
Expand Down
6 changes: 3 additions & 3 deletions image_classification/MobileViT/main_multi_gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,11 +370,11 @@ def main_worker(*args):
# set lr according to batch size and world size (hacked from Swin official code and modified for CSwin)
if config.TRAIN.LINEAR_SCALED_LR is not None:
linear_scaled_lr = (
config.TRAIN.BASE_LR * config.DATA.BATCH_SIZE) / config.TRAIN.LINEAR_SCALED_LR
config.TRAIN.BASE_LR * config.DATA.BATCH_SIZE * world_size) / config.TRAIN.LINEAR_SCALED_LR
linear_scaled_warmup_start_lr = (
config.TRAIN.WARMUP_START_LR * config.DATA.BATCH_SIZE) / config.TRAIN.LINEAR_SCALED_LR
config.TRAIN.WARMUP_START_LR * config.DATA.BATCH_SIZE * world_size) / config.TRAIN.LINEAR_SCALED_LR
linear_scaled_end_lr = (
config.TRAIN.END_LR * config.DATA.BATCH_SIZE) / config.TRAIN.LINEAR_SCALED_LR
config.TRAIN.END_LR * config.DATA.BATCH_SIZE * world_size) / config.TRAIN.LINEAR_SCALED_LR

if config.TRAIN.ACCUM_ITER > 1:
linear_scaled_lr = linear_scaled_lr * config.TRAIN.ACCUM_ITER
Expand Down
6 changes: 3 additions & 3 deletions image_classification/PVTv2/main_multi_gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,11 +370,11 @@ def main_worker(*args):
# set lr according to batch size and world size (hacked from Swin official code and modified for CSwin)
if config.TRAIN.LINEAR_SCALED_LR is not None:
linear_scaled_lr = (
config.TRAIN.BASE_LR * config.DATA.BATCH_SIZE) / config.TRAIN.LINEAR_SCALED_LR
config.TRAIN.BASE_LR * config.DATA.BATCH_SIZE * world_size) / config.TRAIN.LINEAR_SCALED_LR
linear_scaled_warmup_start_lr = (
config.TRAIN.WARMUP_START_LR * config.DATA.BATCH_SIZE) / config.TRAIN.LINEAR_SCALED_LR
config.TRAIN.WARMUP_START_LR * config.DATA.BATCH_SIZE * world_size) / config.TRAIN.LINEAR_SCALED_LR
linear_scaled_end_lr = (
config.TRAIN.END_LR * config.DATA.BATCH_SIZE) / config.TRAIN.LINEAR_SCALED_LR
config.TRAIN.END_LR * config.DATA.BATCH_SIZE * world_size) / config.TRAIN.LINEAR_SCALED_LR

if config.TRAIN.ACCUM_ITER > 1:
linear_scaled_lr = linear_scaled_lr * config.TRAIN.ACCUM_ITER
Expand Down
6 changes: 3 additions & 3 deletions image_classification/PiT/main_multi_gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,11 +394,11 @@ def main_worker(*args):
# set lr according to batch size and world size (hacked from Swin official code and modified for CSwin)
if config.TRAIN.LINEAR_SCALED_LR is not None:
linear_scaled_lr = (
config.TRAIN.BASE_LR * config.DATA.BATCH_SIZE) / config.TRAIN.LINEAR_SCALED_LR
config.TRAIN.BASE_LR * config.DATA.BATCH_SIZE * world_size) / config.TRAIN.LINEAR_SCALED_LR
linear_scaled_warmup_start_lr = (
config.TRAIN.WARMUP_START_LR * config.DATA.BATCH_SIZE) / config.TRAIN.LINEAR_SCALED_LR
config.TRAIN.WARMUP_START_LR * config.DATA.BATCH_SIZE * world_size) / config.TRAIN.LINEAR_SCALED_LR
linear_scaled_end_lr = (
config.TRAIN.END_LR * config.DATA.BATCH_SIZE) / config.TRAIN.LINEAR_SCALED_LR
config.TRAIN.END_LR * config.DATA.BATCH_SIZE * world_size) / config.TRAIN.LINEAR_SCALED_LR

if config.TRAIN.ACCUM_ITER > 1:
linear_scaled_lr = linear_scaled_lr * config.TRAIN.ACCUM_ITER
Expand Down
6 changes: 3 additions & 3 deletions image_classification/PoolFormer/main_multi_gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,11 +360,11 @@ def main_worker(*args):
# set lr according to batch size and world size (hacked from Swin official code and modified for CSwin)
if config.TRAIN.LINEAR_SCALED_LR is not None:
linear_scaled_lr = (
config.TRAIN.BASE_LR * config.DATA.BATCH_SIZE) / config.TRAIN.LINEAR_SCALED_LR
config.TRAIN.BASE_LR * config.DATA.BATCH_SIZE * world_size) / config.TRAIN.LINEAR_SCALED_LR
linear_scaled_warmup_start_lr = (
config.TRAIN.WARMUP_START_LR * config.DATA.BATCH_SIZE) / config.TRAIN.LINEAR_SCALED_LR
config.TRAIN.WARMUP_START_LR * config.DATA.BATCH_SIZE * world_size) / config.TRAIN.LINEAR_SCALED_LR
linear_scaled_end_lr = (
config.TRAIN.END_LR * config.DATA.BATCH_SIZE) / config.TRAIN.LINEAR_SCALED_LR
config.TRAIN.END_LR * config.DATA.BATCH_SIZE * world_size) / config.TRAIN.LINEAR_SCALED_LR

if config.TRAIN.ACCUM_ITER > 1:
linear_scaled_lr = linear_scaled_lr * config.TRAIN.ACCUM_ITER
Expand Down
6 changes: 3 additions & 3 deletions image_classification/T2T_ViT/main_multi_gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,11 +370,11 @@ def main_worker(*args):
# set lr according to batch size and world size (hacked from Swin official code and modified for CSwin)
if config.TRAIN.LINEAR_SCALED_LR is not None:
linear_scaled_lr = (
config.TRAIN.BASE_LR * config.DATA.BATCH_SIZE) / config.TRAIN.LINEAR_SCALED_LR
config.TRAIN.BASE_LR * config.DATA.BATCH_SIZE * world_size) / config.TRAIN.LINEAR_SCALED_LR
linear_scaled_warmup_start_lr = (
config.TRAIN.WARMUP_START_LR * config.DATA.BATCH_SIZE) / config.TRAIN.LINEAR_SCALED_LR
config.TRAIN.WARMUP_START_LR * config.DATA.BATCH_SIZE * world_size) / config.TRAIN.LINEAR_SCALED_LR
linear_scaled_end_lr = (
config.TRAIN.END_LR * config.DATA.BATCH_SIZE) / config.TRAIN.LINEAR_SCALED_LR
config.TRAIN.END_LR * config.DATA.BATCH_SIZE * world_size) / config.TRAIN.LINEAR_SCALED_LR

if config.TRAIN.ACCUM_ITER > 1:
linear_scaled_lr = linear_scaled_lr * config.TRAIN.ACCUM_ITER
Expand Down
6 changes: 3 additions & 3 deletions image_classification/ViP/main_multi_gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,11 +360,11 @@ def main_worker(*args):
# set lr according to batch size and world size (hacked from Swin official code)
if config.TRAIN.LINEAR_SCALED_LR is not None:
linear_scaled_lr = (
config.TRAIN.BASE_LR * config.DATA.BATCH_SIZE) / config.TRAIN.LINEAR_SCALED_LR
config.TRAIN.BASE_LR * config.DATA.BATCH_SIZE * world_size) / config.TRAIN.LINEAR_SCALED_LR
linear_scaled_warmup_start_lr = (
config.TRAIN.WARMUP_START_LR * config.DATA.BATCH_SIZE) / config.TRAIN.LINEAR_SCALED_LR
config.TRAIN.WARMUP_START_LR * config.DATA.BATCH_SIZE * world_size) / config.TRAIN.LINEAR_SCALED_LR
linear_scaled_end_lr = (
config.TRAIN.END_LR * config.DATA.BATCH_SIZE) / config.TRAIN.LINEAR_SCALED_LR
config.TRAIN.END_LR * config.DATA.BATCH_SIZE * world_size) / config.TRAIN.LINEAR_SCALED_LR

if config.TRAIN.ACCUM_ITER > 1:
linear_scaled_lr = linear_scaled_lr * config.TRAIN.ACCUM_ITER
Expand Down
6 changes: 3 additions & 3 deletions image_classification/XCiT/main_multi_gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,11 +359,11 @@ def main_worker(*args):
# set lr according to batch size and world size (hacked from Swin official code and modified for CSwin)
if config.TRAIN.LINEAR_SCALED_LR is not None:
linear_scaled_lr = (
config.TRAIN.BASE_LR * config.DATA.BATCH_SIZE) / config.TRAIN.LINEAR_SCALED_LR
config.TRAIN.BASE_LR * config.DATA.BATCH_SIZE * world_size) / config.TRAIN.LINEAR_SCALED_LR
linear_scaled_warmup_start_lr = (
config.TRAIN.WARMUP_START_LR * config.DATA.BATCH_SIZE) / config.TRAIN.LINEAR_SCALED_LR
config.TRAIN.WARMUP_START_LR * config.DATA.BATCH_SIZE * world_size) / config.TRAIN.LINEAR_SCALED_LR
linear_scaled_end_lr = (
config.TRAIN.END_LR * config.DATA.BATCH_SIZE) / config.TRAIN.LINEAR_SCALED_LR
config.TRAIN.END_LR * config.DATA.BATCH_SIZE * world_size) / config.TRAIN.LINEAR_SCALED_LR

if config.TRAIN.ACCUM_ITER > 1:
linear_scaled_lr = linear_scaled_lr * config.TRAIN.ACCUM_ITER
Expand Down