Skip to content

refactor: replace LambdaLR with PolynomialLR in segmentation training script #6405

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

Merged
Merged
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
5 changes: 3 additions & 2 deletions references/segmentation/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import utils
from coco_utils import get_coco
from torch import nn
from torch.optim.lr_scheduler import PolynomialLR
from torchvision.transforms import functional as F, InterpolationMode


Expand Down Expand Up @@ -184,8 +185,8 @@ def main(args):
scaler = torch.cuda.amp.GradScaler() if args.amp else None

iters_per_epoch = len(data_loader)
main_lr_scheduler = torch.optim.lr_scheduler.LambdaLR(
optimizer, lambda x: (1 - x / (iters_per_epoch * (args.epochs - args.lr_warmup_epochs))) ** 0.9
main_lr_scheduler = PolynomialLR(
optimizer, total_steps=iters_per_epoch * (args.epochs - args.lr_warmup_epochs), power=0.9
)

if args.lr_warmup_epochs > 0:
Expand Down