Fix PyTorch Lightning warning when using torchCPUTrainer#391
Merged
Fix PyTorch Lightning warning when using torchCPUTrainer#391
Conversation
- Replace silent failure (print + return None) with proper FileNotFoundError - Provide clear error message when the specified file does not exist - Bump library version
- Check for _trainer attribute before calling self.log() to avoid RuntimeError - Prevents warning: 'self.trainer reference is not registered on the model yet' - Fixes issue when using custom trainers that don't attach PyTorch Lightning trainer
- Add random seed initialization (Python, NumPy, PyTorch) at module and test level - Adjust test_all_vs_all assertion bounds to reflect reproducible behavior (0.15-0.25) - Set deterministic behavior for PyTorch backends - All 4 tests now pass consistently
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 PR fixes the PyTorch Lightning warning that appeared when using custom trainers like torchCPUTrainer.
Changes:
dicee/models/base_model.pyto check for_trainerattribute before callingself.log()dicee/models/transformers.pywith the same fixIssue Fixed:
Previously, when using
torchCPUTrainer, the following warning appeared:Testing:
Tested with:
The warning no longer appears and training completes successfully.