0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Optunaのdashboardコマンドを試してみる

Posted at

Optunaについて

非常に便利なハイパーパラメータ探索ライブラリ。あのPFNが開発していることでも有名。いくつかQiitaにも詳細な記事があるのでキーワード Optunaで調べれば出ます。

後続のほうでDBファイルを参照していますが、Qiitaのこちらの記事などが良いと思います。

optuna入門
https://qiita.com/studio_haneya/items/2dc3ba9d7cafa36ddffa

コマンドオプション確認

コマンドオプションを見ると気になるコマンド”dashboard”があります。

コマンドオプション確認
$ optuna --help
usage: optuna [--version] [-v | -q] [--log-file LOG_FILE] [-h] [--debug]
              [--storage STORAGE]

optional arguments:
  --version            show program's version number and exit
  -v, --verbose        Increase verbosity of output. Can be repeated.
  -q, --quiet          Suppress output except warnings and errors.
  --log-file LOG_FILE  Specify a file to log output. Disabled by default.
  -h, --help           Show help message and exit.
  --debug              Show tracebacks on errors.
  --storage STORAGE    DB URL. (e.g. sqlite:///example.db)

Commands:
  complete       print bash completion command (cliff)
  create-study   Create a new study.
  dashboard      Launch web dashboard (beta).
  delete-study   Delete a specified study.
  help           print detailed help for another command (cliff)
  storage upgrade  Upgrade the schema of a storage.
  studies        Show a list of studies.
  study optimize  Start optimization of a study. Deprecated since version 2.0.0.
  study set-user-attr  Set a user attribute to a study.

Study一覧表示

引数としてStudyを指定する必要があるので、一覧で確認します。
関係者は気づくかもしれませんが、最適化問題のバランスパラメータ調整です。

実行(study)結果出力
$ optuna studies --storage 'sqlite:///optuna_study.db'
+------------------------------------+-----------+----------+---------------------+
| NAME                               | DIRECTION | N_TRIALS | DATETIME_START      |
+------------------------------------+-----------+----------+---------------------+
| tsp_6_500_DW_2000Q_6               | MINIMIZE  |      300 | 2020-10-19 21:21:39 |
| tsp_fix_6_500_DW_2000Q_6           | MINIMIZE  |      100 | 2020-10-19 22:48:09 |
| tsp_fix_6_500_Advantage_system1.1  | MINIMIZE  |      255 | 2020-10-19 22:58:48 |
| tsp_fix_7_500_Advantage_system1.1  | MINIMIZE  |      400 | 2020-10-19 23:27:57 |
| tsp_fix_7_500_DW_2000Q_6           | MINIMIZE  |      201 | 2020-10-19 23:50:28 |
| tsp_fix_8_500_Advantage_system1.1  | MINIMIZE  |      200 | 2020-10-20 08:01:28 |
| tsp_fix_8_500_DW_2000Q_6           | MINIMIZE  |      200 | 2020-10-20 08:41:51 |
| tsp_fix_9_500_Advantage_system1.1  | MINIMIZE  |      170 | 2020-10-20 09:10:33 |
| tsp_fix_10_500_Advantage_system1.1 | MINIMIZE  |      400 | 2020-10-20 13:24:42 |
| tsp_fix_11_500_Advantage_system1.1 | MINIMIZE  |      400 | 2020-10-20 14:08:12 |
| tsp_fix_12_500_Advantage_system1.1 | MINIMIZE  |      400 | 2020-10-20 15:01:40 |
| tsp_fix_13_500_Advantage_system1.1 | MINIMIZE  |      123 | 2020-10-20 16:08:39 |
+------------------------------------+-----------+----------+---------------------+

関連のライブラリインストール

表示にbokehが必要なようなので、インストールします。普通にインストールすると新しすぎるようなので、要求されるバージョンをインストール。

# python3 -m pip install 'bokeh<2.0.0'

Optunaのコマンドでダッシュボード起動

見たいStudyを引数にOptuna Dashboardを起動します。 FireFoxなどをインストールしてから実行しましょう。

$ optuna dashboard --study-name "tsp_fix_7_500_Advantage_system1.1" --storage 'sqlite:///optuna_study.db'
/home/monta/.local/lib/python3.6/site-packages/optuna/dashboard.py:271: ExperimentalWarning: Optuna dashboard is experimental (supported from v0.1.0). The interface can change in the future.
  _show_experimental_warning()
[I 2020-10-20 22:06:22,870] Starting Bokeh server version 1.4.0 (running on Tornado 6.0.4)
[I 2020-10-20 22:06:22,871] User authentication hooks NOT provided (default user enabled)
[I 2020-10-20 22:06:22,873] Bokeh app running at: http://localhost:5006/dashboard
[I 2020-10-20 22:06:22,873] Starting Bokeh server with process id: 12953

(firefox:13096): LIBDBUSMENU-GLIB-WARNING **: 22:06:23.524: Unable to get session bus: Failed to execute child process “dbus-launch” (No such file or directory)
[I 2020-10-20 22:06:23,774] 200 GET /dashboard (127.0.0.1) 192.89ms
[I 2020-10-20 22:06:24,195] 101 GET /dashboard/ws?bokeh-protocol-version=1.0&bokeh-session-id=zdXJAn8ixdmj9iNId4Kq465ZJJasMd6YXCsMMVzghkzo (127.0.0.1) 0.63ms
[I 2020-10-20 22:06:24,196] WebSocket connection opened
[I 2020-10-20 22:06:24,196] ServerConnection created
[I 2020-10-20 22:06:24,295] 200 GET /dashboard (127.0.0.1) 54.78ms
[I 2020-10-20 22:06:24,342] 200 GET /static/js/bokeh.min.js?v=ac90935137e13ae0b2c6583f2e1f3fe8 (127.0.0.1) 2.92ms
[I 2020-10-20 22:06:24,344] 200 GET /static/js/bokeh-widgets.min.js?v=bbfecfaf62fc48a3f557280273185467 (127.0.0.1) 1.63ms
[I 2020-10-20 22:06:24,345] 200 GET /static/js/bokeh-tables.min.js?v=35738715f747a3f5672b245db261f9bc (127.0.0.1) 1.84ms
[I 2020-10-20 22:06:24,346] 200 GET /static/js/bokeh-gl.min.js?v=817fa55a6e55d1e469275e21c9b77565 (127.0.0.1) 2.02ms
[W 2020-10-20 22:06:24,680] 404 GET /favicon.ico (127.0.0.1) 0.45ms
[I 2020-10-20 22:06:24,730] 101 GET /dashboard/ws?bokeh-protocol-version=1.0&bokeh-session-id=hw73xCUxcMmFAQGWLr1NuY19XwxTONbhW4yOObFzl2Zz (127.0.0.1) 0.59ms
[I 2020-10-20 22:06:24,730] WebSocket connection opened
[I 2020-10-20 22:06:24,731] ServerConnection created
[I 2020-10-20 22:06:27,235] WebSocket connection closed: code=1001, reason=None

WSLでもXなどをちゃんと設定しておけば、自動的にFireFoxが起動してStudyの内容を見ることができます。

SnapCrab_NoName_2020-10-20_22-10-49_No-00.png

以上

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?