optuna / optunahub-registry

The registry of the OptunaHub packages
https://hub.optuna.org/
MIT License
32 stars 30 forks source link

Fix INGO implementation #125

Closed not522 closed 3 months ago

not522 commented 3 months ago

Contributor Agreements

Please read the contributor agreements and if you agree, please click the checkbox below.

[!TIP] Please follow the Quick TODO list to smoothly merge your PR.

Motivation

The implementation of ImplicitNaturalGradientSampler contains bugs. This PR fixes them and improves the sampling speed.

Description of the changes

I have checked the implementation with the following code.

import optuna
import optunahub

def objective_L1_Ellipsoid(trial):
    DIMENSION = 100
    xs = [trial.suggest_float(f"x{n}", -1.0, 1.0) for n in range(DIMENSION)]
    return sum(10**(6*i/(DIMENSION-1))*abs(xs[i]) for i in range(DIMENSION))

mod = optunahub.load_local_module(
    package="samplers/implicit_natural_gradient",
    registry_root="./package",
    force_reload=True,
)

sampler = mod.ImplicitNaturalGradientSampler(seed=42)
study = optuna.create_study(sampler=sampler)
study.optimize(objective_L1_Ellipsoid, n_trials=10000)

The best value:

TODO List towards PR Merge