-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Created regression_system and updated check_loss #71
base: main
Are you sure you want to change the base?
Conversation
modified: malpolon/models/standard_prediction_systems.py modified: malpolon/models/utils.py
malpolon/models/utils.py
Outdated
@@ -118,7 +118,9 @@ def check_loss(loss: nn.modules.loss._Loss) -> nn.modules.loss._Loss: | |||
""" | |||
if isinstance(loss, nn.modules.loss._Loss): # pylint: disable=protected-access # noqa | |||
return loss | |||
raise ValueError(f"Loss must be of type nn.modules.loss. " | |||
elif isinstance(loss, str): | |||
return eval(loss) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are aiming at removing all calls to eval()
for security purposes. Please take a look at functions check_optimizer()
, check_scheduler()
or check_metrics()
, on our new branch "no-more-evals" to get an understanding at what a similar check_loss()
function should look like
lr: float = 1e-2, | ||
weight_decay: float = 0, | ||
metrics: Optional[dict[str, Callable]] = None, | ||
task: str = 'regression_multilabel', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Argument not used
|
||
class RegressionSystem(GenericPredictionSystem): | ||
"""Regression task class.""" | ||
def __init__( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some arguments (optimizer kwargs) are not used because incompatible with the proposed default optimizer. I suggest replacing them with the default optimizer's; or simply removing them.
Please update the docstring accordingly too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The RegressionSystem class might be redundant with #66 but as the later is scheduler to take more time to be fully completed, and considering this PR is a smaller I think I'll merge this one 1st.
Also, it raises the quesiton of updating check_loss() in a similar fashion as has been done with the other "check" functions, which is good.
modified: malpolon/models/standard_prediction_systems.py modified: malpolon/models/utils.py
modified: malpolon/models/utils.py
Merge changes from version 2.1.1
Stay up to date with upstream
Merging upstream changes
Updated loss check in RegressionSystem.__init__ to allow custom losses
📝 Changelog
In malpolon/models/standard_prediction_systems.py: Added a generic RegressionSystem
In malpolon/models/utils.py: