Code Monkey home page Code Monkey logo

Comments (3)

JohnGiorgi avatar JohnGiorgi commented on May 23, 2024 1

@himkt That's great! This is exactly what I was looking for. I will try this out :)

from allennlp-optuna.

himkt avatar himkt commented on May 23, 2024 1

@JohnGiorgi Let me close this issue. Please feel free to reopen if you need! 👋

from allennlp-optuna.

himkt avatar himkt commented on May 23, 2024

Thank you @JohnGiorgi for raising the interesting issue.

You would like to set a fixed parameter set like the following?:

import optuna


def objective(trial):
    x = trial.suggest_float("x", 0, 10)
    return x ** 2


study = optuna.create_study()
study.enqueue_trial({"x": 5})  # set a parameter x=5 for the first trial
study.enqueue_trial({"x": 0})  # then set x=0 for the next trial
study.optimize(objective, n_trials=2)

assert study.trials[0].params == {"x": 5}  # x=5 in the first trial
assert study.trials[1].params == {"x": 0}  # x=0 in the second trial

https://optuna.readthedocs.io/en/stable/reference/generated/optuna.study.Study.html#optuna.study.Study.enqueue_trial

If my understanding is correct, the answer is (partially) yes. allennlp-optuna doesn't provide a way to set predefined parameter combinations but we can load an existing study by --skip-if-exists option. So I think we can realize that by the following two steps:

1. create study and set manual hyperparameters in Python

> python
>> import optuna
>> study = optuna.craete_study(storage="sqlite:///sample.db", study_name="some_name")
>> study.enqueue_trial({"x1": your_awesome_parameter, "x2": your_awesome_parameter})
>> exit()

2. use the study in allennlp-optuna

allennlp tune ... --study some_name --storage sqlite:///sample.db --skip-if-exists

from allennlp-optuna.

Related Issues (17)

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.