How to set optuna's study.optimize verbosity to 0?
Asked Answered
H

2

9

I want to set optuna's study.optimize verbosity to 0. I thought optuna.logging.set_verbosity(0) might do it, but I still get the Trial 0 finished with value .... updates for every trial

What is the correct way to do this? Unfortunately, extensive searching through the docs still only results in the above method.

Many thanks in advance

Hyphenated answered 11/6, 2021 at 15:3 Comment(2)
Have you tried optuna.logging.set_verbosity(optuna.logging.ERROR)?Sensational
@FlaviaGiammarino I haven't, I'll try that, what will that do? change trial updates to just printing error messages?Hyphenated
G
12

Try this:

optuna.logging.set_verbosity(optuna.logging.WARNING)

It basically changes the level of verbosity.

For more level choices, check optuna's official guides here.

Gyroplane answered 7/11, 2021 at 4:36 Comment(0)
B
2

optuna warnings tend to be raised using standard pythonic warnings.warn() (which explains why optuna.logging.set_verbosity() does not always work to suppress them), so you can silence them all at once with:

# treat all python warnings as lower-level "ignore" events
warnings.filterwarnings("ignore")

Be aware however, that this will silence also the useful and infrequent ones like deprecation warnings.

Bottommost answered 28/8, 2021 at 5:5 Comment(2)
how to set it back warnings.filterwarnings("ignore")? `Mechanist
To reset it back to default, you can use warnings.filterwarnings("default") or perhaps limit the scope of the original "ignore" with the context manager (with ... :)Bottommost

© 2022 - 2024 — McMap. All rights reserved.