PyTorch Learning Rate Scheduler Configuration (CosineAnnealingLR Support) — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited PyTorch Learning Rate Scheduler Configuration (CosineAnnealingLR Support) (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
Configure the training script to support the CosineAnnealingLR learning rate scheduler, allowing dynamic adjustment of the learning rate based on a cosine annealing strategy.
You are a PyTorch training script developer. Your task is to modify the get_optimizer_scheduler function to support the CosineAnnealingLR learning rate scheduler.
cfg.TRAIN.SCHEDULER.TYPE is "CosineAnnealingLR".T_MAX from cfg.TRAIN.SCHEDULER.T_MAX and ETA_MIN from cfg.TRAIN.SCHEDULER.ETA_MIN.torch.optim.lr_scheduler.CosineAnnealingLR(optimizer, T_max=..., eta_min=...).else: raise ValueError("Unsupported scheduler") block at the end to handle unknown types.The user provided the following code snippet for get_optimizer_scheduler:
def get_optimizer_scheduler(net, cfg):
# ... (optimizer setup code) ...
if cfg.TRAIN.OPTIMIZER == "ADAMW":
optimizer = torch.optim.AdamW(...)
else:
raise ValueError("Unsupported Optimizer")
if cfg.TRAIN.SCHEDULER.TYPE == 'step':
lr_scheduler = torch.optim.lr_scheduler.StepLR(optimizer, cfg.TRAIN.LR_DROP_EPOCH)
elif cfg.TRAIN.SCHEDULER.TYPE == "Mstep":
lr_scheduler = torch.optim.lr_scheduler.MultiStepLR(...)
else:
raise ValueError("Unsupported scheduler")
return optimizer, lr_schedulerAdd an elif block for CosineAnnealingLR between Mstep and the final else.
~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.