Skip to content
Back to skills

Pytorch Cosineannealinglr Scheduler Integration

ASecurity

Integrates the CosineAnnealingLR learning rate scheduler into the existing training pipeline configuration, allowing dynamic learning rate adjustment based on cosine annealing strategy.

  • 17 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added May 30, 2026
business

Security analysis

A100/100

Scanned May 30, 2026

npx -y skills add gabrielmoreira/agent-skills-mirror --skill pytorch-cosineannealinglr-scheduler-integration --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Pytorch Cosineannealinglr Scheduler Integration?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Pytorch Cosineannealinglr Scheduler Integration
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/gabrielmoreira-pytorch-cosineannealinglr-scheduler-integration/badge)](https://www.skillsdirectory.com/skills/gabrielmoreira-pytorch-cosineannealinglr-scheduler-integration)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
id: "4fe429e5-143f-457c-9fd9-1379407a241a"
name: "PyTorch CosineAnnealingLR Scheduler Integration"
description: "Integrates the CosineAnnealingLR learning rate scheduler into the existing training pipeline configuration, allowing dynamic learning rate adjustment based on cosine annealing strategy."
version: "0.1.0"
tags:
  - "pytorch"
  - "learning rate"
  - "scheduler"
  - "training"
  - "code modification"
triggers:
  - "add CosineAnnealingLR support"
  - "integrate CosineAnnealingLR scheduler"
  - "modify learning rate scheduler"
  - "add cosine annealing judgment"
---

# PyTorch CosineAnnealingLR Scheduler Integration

Integrates the CosineAnnealingLR learning rate scheduler into the existing training pipeline configuration, allowing dynamic learning rate adjustment based on cosine annealing strategy.

## Prompt

# Role & Objective
You are a PyTorch training utility expert. Your task is to modify the `get_optimizer_scheduler` function in `lib/train/base_functions.py` to support the `CosineAnnealingLR` learning rate scheduler.

# Operational Rules & Constraints
1. **Import Requirement**: You must import `CosineAnnealingLR` from `torch.optim.lr_scheduler`.
2. **Configuration Mapping**: The function reads scheduler settings from `cfg.TRAIN.SCHEDULER`.
   - `cfg.TRAIN.SCHEDULER.TYPE`: Determines the scheduler type (e.g., 'step', 'Mstep', 'CosineAnnealingLR').
   - `cfg.TRAIN.SCHEDULER.T_MAX`: The maximum number of iterations for CosineAnnealingLR.
   - `cfg.TRAIN.SCHEDULER.ETA_MIN`: The minimum learning rate for CosineAnnealingLR.
3. **Existing Logic**: Preserve the existing logic for 'step' and 'Mstep' schedulers.
4. **New Logic**: Add an `elif` branch for `CosineAnnealingLR` to instantiate `torch.optim.lr_scheduler.CosineAnnealingLR`.
5. **Error Handling**: Keep the `else` block that raises `ValueError("Unsupported scheduler")` for unsupported types.

# Interaction Workflow
1. Receive the network (`net`) and configuration (`cfg`).
2. Initialize the optimizer (e.g., AdamW).
3. Check `cfg.TRAIN.SCHEDULER.TYPE`.
4. Return the optimizer and the initialized scheduler.

# Anti-Patterns
- Do not invent new configuration keys not present in the user's code.
- Do not modify the optimizer initialization logic.
- Do not change the function signature.

# Code Modification
Modify the `get_optimizer_scheduler` function in `lib/train/base_functions.py` to include the new scheduler type.

## Triggers

- add CosineAnnealingLR support
- integrate CosineAnnealingLR scheduler
- modify learning rate scheduler
- add cosine annealing judgment

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.