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

How to get candidate solutions from each iteration? #72

Open
BruthYU opened this issue Oct 25, 2022 · 3 comments
Open

How to get candidate solutions from each iteration? #72

BruthYU opened this issue Oct 25, 2022 · 3 comments

Comments

@BruthYU
Copy link

BruthYU commented Oct 25, 2022

Thanks for the excellent work πŸ₯³

  1. I'm looking for black-box optimization algorithms to perform prompt tuning on my neural network, which requires candidate solutions from each iteration.
  2. Following the β€œask-tell” form of pycma, the pseudo-code is shown as below:
while not es.stop():
    solutions = es.ask()
    fitness = [cma.ff.rosen(s) for s in solutions]
    es.tell(solutions, fitness)
  1. Question: How can I obtain the solutions from each iteration to calculate new fitness (e.g. loss functions)?
@Evolutionary-Intelligence
Copy link
Owner

Thanks for your interest. Currently this libaray does not return the solution from each iteration by default. We only return the solution value for saving memory. For large-scale black-box optimization, typically returning the solutions from each iteration is memory-expensive ().

However, it is possible to do this via slightly modifying the code.
Here is a related example: https://github.com/Evolutionary-Intelligence/pypop/blob/main/pypop7/optimizers/es/_repeat_fmaes.py#L74

In fact, you only need to add a variable to record it (I think this is a very simple coding task since all the optimizer class are OOP).

@Evolutionary-Intelligence
Copy link
Owner

If you still have questions, you can write a simple demo. And I can help to add them. Thanks for your interest again.

@twoletters
Copy link

twoletters commented Feb 1, 2023

I find myself in the same situation. My fitness function is costly and its computation needs to be distributed. The ask/tell interface of pycma makes it easy to do so, but I cannot see an easy way to achieve the same with pypop. Overriding method iterate might work but not without deep changes to my code base.
I understand the philosophy behind the current design choices. However, providing a ask/tell interface compatible with pycma's would encourage pycma users to swap it out for pypop. Seeing that this is one of the very best BBO libraries around, it would surely attract users. What do you think?

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

3 participants