Created
November 27, 2024 09:25
-
-
Save porink0424/e43886aa85f7962cf4814703e1db99af to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import optuna | |
| from concurrent.futures import ThreadPoolExecutor | |
| optuna.logging.set_verbosity(optuna.logging.WARNING) | |
| def test_free_threaded(): | |
| study = optuna.create_study(sampler=optuna.samplers.BruteForceSampler()) | |
| def objective(trial): | |
| s = 0 | |
| for i in range(10): | |
| s += trial.suggest_int(f"x{i}", 0, 10) | |
| return s | |
| study.optimize( | |
| objective, | |
| n_trials=50, | |
| n_jobs=5, | |
| ) | |
| if __name__ == "__main__": | |
| with ThreadPoolExecutor() as executor: | |
| for _ in range(5): | |
| executor.submit(test_free_threaded) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment