Fix torch.load device handling and remove deprecated scheduler params#134
Open
Aryanjstar wants to merge 1 commit intoML4SCI:mainfrom
Open
Fix torch.load device handling and remove deprecated scheduler params#134Aryanjstar wants to merge 1 commit intoML4SCI:mainfrom
Aryanjstar wants to merge 1 commit intoML4SCI:mainfrom
Conversation
- 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.loadwithmap_location=deviceandweights_only=Truefor 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:
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:
verboseparameter from the initialization ofCosineAnnealingWarmRestartsandOneCycleLRlearning 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.