GithubHelp home page GithubHelp logo

Comments (8)

lena-kashtelyan avatar lena-kashtelyan commented on April 20, 2024

@aagarwal1999, yep, there is –– you will need to make a custom generation strategy. You can get one by resetting it right after your experiment:

ax_client = AxClient()
ax_client.create_experiment(...)
ax_client.generation_strategy = choose_generation_strategy(
    search_space=ax_client.experiment.search_space,
    random_seed=239,  # Whatever random seed you want.
)

You can import choose_generation_strategy from here:

def choose_generation_strategy(

Then, you will need to set the torch seed before each call to ax_client.get_next_trial, like so: torch.manual_seed(1000). More on the torch seed in this issue: #95.

Let me know if that fully solves the issue.

from ax.

aagarwal1999 avatar aagarwal1999 commented on April 20, 2024

I am getting an error stating:

TypeError: choose_generation_strategy() got an unexpected keyword argument 'random_seed'

I suspect this is due to the fact that I am not using the latest version of Ax. However, when I updated to the latest version, I was getting an import error when I try and import AxClient

File "/mnt/nfs/home/ankit/.conda/envs/dstorch-ankit/lib/python3.6/site-packages/ax/models/torch/botorch_defaults.py", line 21, in <module> from botorch.optim.optimize import optimize_acqf ImportError: cannot import name 'optimize_acqf'

from ax.

lena-kashtelyan avatar lena-kashtelyan commented on April 20, 2024

@aagarwal1999, you're right that the argument was unexpected because you had a later version; the BoTorch defaults import error, however, is news to me. Did you try to update BoTorch also?

from ax.

aagarwal1999 avatar aagarwal1999 commented on April 20, 2024

That fixed it! Thanks

from ax.

lena-kashtelyan avatar lena-kashtelyan commented on April 20, 2024

@aagarwal1999, also, I didn't know this when I responded to your question, but setting the random seed this say in the long run is non-ideal as it sets the seed for torch globally, which may impact model performance. I will have a fix for this on master by tomorrow –– will add a random_seed top-level argument to AxClient instantiation, which should make the seed safer to use.

from ax.

aagarwal1999 avatar aagarwal1999 commented on April 20, 2024

Hi, has the fix been implemented for the AxClient seed?

from ax.

lena-kashtelyan avatar lena-kashtelyan commented on April 20, 2024

Hi, Ankit! Not yet, but a partial fix will be on master soon (possibly today; I will update this issue like I said I would). Partial, because there isn't a way to fully make the Bayesian optimization part of the process reproducible (that is safe; I learned that setting the torch.manual_seed is not safe for the model performance). When we fix the torch seed, it's fixed globally, which can have drastic negative effects on the performance of the BoTorch-backed models, which we use for Bayesian optimization (that's what we are doing through the ad-hoc solution you are using now).

Now, the partial fix will provide a random seed setting to AxClient, which will make the initial quasi-random trials fully reproducible and the subsequent trials somewhat reproducible (but as you generate more trials, they will start differing more and more).

Finally, if you want reproducibility because you want your Ax optimization to use data from previous optimization, you can attach those trials via attach_trial and the data will be used in optimization. However, do make sure that those trials are actually applicable to the new optimization (for example, if you evaluate the trials on some data that has non-stationarity, then attaching data from an old optimization will worsen your new optimization results).

Let me know if that helps / makes sense!

from ax.

lena-kashtelyan avatar lena-kashtelyan commented on April 20, 2024

Closing this issue because the random_seed argument for AxClient is now included into the latest stable version –– 0.1.5. Note that it does not make optimization fully reproducible, as described above.

from ax.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.