Skip to content

Fix torch.load device handling and remove deprecated scheduler params#134

Open
Aryanjstar wants to merge 1 commit intoML4SCI:mainfrom
Aryanjstar:fix/pipeline-robustness-improvements
Open

Fix torch.load device handling and remove deprecated scheduler params#134
Aryanjstar wants to merge 1 commit intoML4SCI:mainfrom
Aryanjstar:fix/pipeline-robustness-improvements

Conversation

@Aryanjstar
Copy link

@Aryanjstar Aryanjstar commented Feb 10, 2026

This pull request streamlines model loading and scheduler initialization across multiple anomaly detection and classification scripts. The main improvements include standardizing the use of torch.load with map_location=device and weights_only=True for loading model weights, and removing unnecessary verbosity from learning rate scheduler initialization. This results in cleaner, more maintainable, and device-agnostic code.

Model Loading Improvements:

  • Replaced conditional logic for device-specific model loading with a unified approach using torch.load(MODEL_PATH, map_location=device, weights_only=True) for all models in both anomaly detection and classification pipelines. This change affects autoencoders, variational autoencoders, adversarial autoencoders, and classification models, ensuring consistent and robust loading behavior regardless of device. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14]

Scheduler Initialization Cleanup:

  • Removed the verbose parameter from the initialization of CosineAnnealingWarmRestarts and OneCycleLR learning rate schedulers, simplifying their usage and reducing unnecessary output in both anomaly detection and classification training scripts. [1] [2] [3] [4]

These changes collectively make the codebase more maintainable and less error-prone, especially when running on different devices or in production environments.

- Use map_location=device consistently instead of branching on device type
- Add weights_only=True to address PyTorch FutureWarning
- Remove deprecated verbose parameter from LR schedulers
- Applies across Classification, Regression, and Anomaly Detection pipelines
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant