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

Optimizer kwargs should be passed as a dictionary rather than implicitly #106

Closed
maurapintor opened this issue Oct 10, 2024 · 1 comment
Closed
Assignees
Labels
enhancement New feature or request refactoring Improvements that don't add or modify functionalities.

Comments

@maurapintor
Copy link
Collaborator

The parameters passed to the run should be explicitly passed as optimizer kwargs incapsulated as a dictionary, rather than passing whichever additional input to the optimizer.

This also allow to extend the interface to pass other inputs to other parts of the run, e.g., the forward.

def _run(
self,
model: BaseModel,
samples: torch.Tensor,
labels: torch.Tensor,
init_deltas: torch.Tensor = None,
**optim_kwargs,
) -> tuple[torch.Tensor, torch.Tensor]:

Should be changed to

def _run(
        self,
        model: BaseModel,
        samples: torch.Tensor,
        labels: torch.Tensor,
        init_deltas: torch.Tensor = None,
        optim_kwargs: dict = dict(),  # pass as explicit dictionary
    ) -> tuple[torch.Tensor, torch.Tensor]:
@maurapintor maurapintor added enhancement New feature or request refactoring Improvements that don't add or modify functionalities. labels Oct 10, 2024
@maurapintor maurapintor self-assigned this Oct 10, 2024
@maurapintor
Copy link
Collaborator Author

Closed with #105.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request refactoring Improvements that don't add or modify functionalities.
Projects
None yet
Development

No branches or pull requests

1 participant