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

API change: make __init__ of Optimizer contain the Domain and DataGenerator #12

Open
mpvanderschelling opened this issue Nov 11, 2024 · 0 comments

Comments

@mpvanderschelling
Copy link
Collaborator

Optimization needs 2 things: the parameters space and the loss function.

Current state

Now, the update_step requires the DataGeneration. It would be cleaner if this data generator is stored as a self.data_generator argument during creation of the Optimizer

Requested change

These two arguments should be required during creation of the object.
Also then the _construct_model method can collapse into the __init__ or __post_init__ if we are using dataclasses again

API for Optimization

There are three ways:

  • Using built-in defaults by importing a function
from f3dasm_optimize import cmaes
experiment_data.optimize(optimizer=cmaes(population=30, seed=123), data_generator = ..., ...)
  • Using built-in default by string argument
experiment_data.optimize(optimizer='cmaes', data_generator = ..., hyperparameters={'population': 30, 'seed':123})
  • Custom optimizer
class MyOptimizer(Optimizer):
    def update_step(self):
           data_generator = self.datagenerator
           data = self.data
           return ExperimentData # new samples

experiment_data.optimize(optimizer=MyOptimizer, data_generator= ... , hyperparameters({'arg1': arg1, 'arg2': arg2})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant