Giter Site home page Giter Site logo

attach trials about ax HOT 8 CLOSED

Fa20 avatar Fa20 commented on September 1, 2024
attach trials

from ax.

Comments (8)

danielcohenlive avatar danielcohenlive commented on September 1, 2024

Hi @Fa20, your code is missing definitions for setup_experiment() and evaluate_parameters(), so I had to guess a little. For me, it works. You may have gotten this error by running your code twice, in which case on

ax_client.complete_trial(trial_index=i, raw_data=result)

i is a list index, say 0. But if there already were 20 trials on the experiment, you're trying to complete trial 0 when you should be trying to complete trial 20. Trial 0 is probably already completed, so this error being raised to save you from silent failures/bad results. You could either fix this by making sure the experiment is clean at the beginning, or by changing

        ax_client.attach_trial(parameters=trial_params)
        result = evaluate_parameters(trial_params)
        ax_client.complete_trial(trial_index=i, raw_data=result)

to

        params, trial_index = ax_client.attach_trial(parameters=trial_params)
        result = evaluate_parameters(trial_params)
        ax_client.complete_trial(trial_index= trial_index, raw_data=result)

like in the loop below. Probably you just want to make sure you start with a clean experiment though.

If this isn't it, please fix your minimal repro and I'll be happy to look again. Your minimal repro should include imports and all, with any private information substituted, so that I can copy and paste it into my own notebook and click run without any modification and see the error (or general problem) you're having.

from ax.

Fa20 avatar Fa20 commented on September 1, 2024

@danielcohenlive thanks for your answer.No I do not want clean and start from the beginning the problem that I need to evaluate the objective functions by simulation which need to keep the Ax code running till to get the result from the simulation and I thought that I can avoid this by stop run the code till the simulation is finished and attach the parmas . Is there in Ax better way to solve this problem in case that I do not want to keep the code running till get the result from Simulation?

from ax.

danielcohenlive avatar danielcohenlive commented on September 1, 2024

Is there in Ax better way to solve this problem in case that I do not want to keep the code running till get the result from Simulation?

@Fa20 could you clarify what you mean by not wanting to keep the code running... If you're talking about running a human in the loop experiment see https://ax.dev/tutorials/human_in_the_loop/human_in_the_loop.html. It's not written in AxClient though, so you'll have to cross reference with the service API tutorial.

from ax.

Fa20 avatar Fa20 commented on September 1, 2024

@danielcohenlive I mean when we run the Loop start the Generation step then evaluate the objective with this values of parameters. In my case I do not have this value of objective functions and I should calculate it Numerical which need some time and the Ax Code should wait till to get this value and then go to the next step .is there any way to that after the first Generation step that we can step excuted the code till the calculation of objective finished and then run it again but this time the step of evaluate the objective can be excuted

from ax.

Abrikosoff avatar Abrikosoff commented on September 1, 2024

@danielcohenlive I mean when we run the Loop start the Generation step then evaluate the objective with this values of parameters. In my case I do not have this value of objective functions and I should calculate it Numerical which need some time and the Ax Code should wait till to get this value and then go to the next step .is there any way to that after the first Generation step that we can step excuted the code till the calculation of objective finished and then run it again but this time the step of evaluate the objective can be excuted

Hi @Fa20, again drive-by commenting, but maybe you can:

  1. run the following (replace the num_trials by however much trials you need):
for i in range(num_trials):

    parameterization, trial_index = ax_client.get_next_trial()

    # extract parameters
    p1 = parameterization["Polymer1"]
    p2 = parameterization["Polymer2"]

    # Save suggestions in the dictionary
    experiment_suggestions[f"Iteration_{i}"] = {
        'Polymer1': p1,
        'Polymer2': p2,
   }
  1. save your ax_client after finishing the loop (probably via ax_client.save_to_json_file; note this saves your ax_client instance, not the data)
  2. do your simulations using data in the saved dictionary;
  3. reload your saved ax_client and do ax_client.complete_trial(), with the correct trial indices.

Probably you can also set up a scheduler, but I'm not sure how that works in Service.

from ax.

Fa20 avatar Fa20 commented on September 1, 2024

@Abrikosoff step 4
Do I need to use for loop
To evaluate the objectives and then complete the trial

from ax.

Abrikosoff avatar Abrikosoff commented on September 1, 2024

@Abrikosoff step 4 Do I need to use for loop To evaluate the objectives and then complete the trial

You probably would want to, although I think you can also partially complete the set of suggested trials. In that case if the remainder is larger than your max_parallelism number (I think!) you won't be able to generate new trials.

from ax.

danielcohenlive avatar danielcohenlive commented on September 1, 2024

@Fa20 it looks like this issue can be closed. If you have further questions, please reopen it.

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.