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

Same results with different seed #93

Open
glatq opened this issue Feb 12, 2025 · 1 comment
Open

Same results with different seed #93

glatq opened this issue Feb 12, 2025 · 1 comment

Comments

@glatq
Copy link

glatq commented Feb 12, 2025

Hi! I am trying to compare some optimizers and wanted to replicate your optimizer evaluation protocol and make the ranks with the percentage of budget you show in your paper. When I try to run the same configuration given different seed in the objective function I get the same results independent of the scenario or instance. If this is supposed to happen, then why did you made 30 replications in your original work? Thank you!

Here is the code that gives me the same results:

from yahpo_gym import * b = BenchmarkSet("lcbench", instance="167168") config = b.get_opt_space().sample_configuration().get_dictionary() res1 = b.objective_function(config, seed=1, logging=True) res2 = b.objective_function(config, seed=123, logging=True) print(res1) print(res2)

which returns

[{'time': 39.226597, 'val_accuracy': 66.65739, 'val_cross_entropy': 0.8803897, 'val_balanced_accuracy': 0.67849356, 'test_cross_entropy': 1.2539272, 'test_balanced_accuracy': 0.677087}]
[{'time': 39.226597, 'val_accuracy': 66.65739, 'val_cross_entropy': 0.8803897, 'val_balanced_accuracy': 0.67849356, 'test_cross_entropy': 1.2539272, 'test_balanced_accuracy': 0.677087}]

@sumny
Copy link
Collaborator

sumny commented Mar 4, 2025

Hi @glatq and sorry for the late reply, it seems like we missed this issue.

Indeed, surrogates in YAHPO Gym are deterministic, i.e., repeatedly evaluating the same configuration will give you the same output.
For a discussion of noisy surrogates, please see https://slds-lmu.github.io/yahpo_gym/frequently_asked.html#noisy-surrogates.
In summary noisy surrogates are currently not supported but eventually will be in a YAHPO Gym v2 (which, however, currently is somewhat on hold).

When running any black-box optimizer on a function (regardless of noisy or deterministic) you still should perform replications.
This is due to different black-box optimizers having stochastic behavior.
For example, a random search will propose different configurations uniformly at random depending on the seed.
Bayesian Optimization will use a different initial design and the surrogate model fit and acquisition function optimization depends on the random seed and therefore the output of running BO on a black-box function in general will not be deterministic.
The same holds for evolutionary algorithms due to parent selection and mutation and crossover operations etc.

I hope this helps!

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

2 participants