Skip to content
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

Avoid the explicit need to create self.criterion and self.optimizer in models #134

Closed
drewoldag opened this issue Dec 7, 2024 · 0 comments · Fixed by #146
Closed

Avoid the explicit need to create self.criterion and self.optimizer in models #134

drewoldag opened this issue Dec 7, 2024 · 0 comments · Fixed by #146
Assignees
Labels
enhancement New feature or request

Comments

@drewoldag
Copy link
Collaborator

Currently the last step in the __init__ function for the built in models is to do this:

self.optimizer = self._optimizer()
self.criterion = self._criterion()

It represents boilerplate code and would be easy to forget.

Python dataclasses have a nice post_init function, but regular classes do not. It seems that functionality like that would be ideal in this case. Since it could be defined in the @fibad_model decorator, and the user wouldn't be required to implement anything.

Alternatively - we could leave this a boilerplate that the user has to write. Doing so would mean that the user would have to be explicitly aware of the fact that they are creating the optimizer and loss function that they think they are.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant