This repository has been archived by the owner on Jun 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
740 lines (649 loc) · 44.1 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" type="image/png" href="./assets/img/favicon.ico">
<link rel="apple-touch-icon" sizes="76x76" href="./assets/img/optuna.png">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Optuna - A hyperparameter optimization framework</title>
<link href="./assets/css/bootstrap.min.css" rel="stylesheet" />
<link href="./assets/css/paper-kit.css?v=2.1.0" rel="stylesheet"/>
<link href="./assets/css/demo.css" rel="stylesheet" />
<link href="./assets/css/prism.css" rel="stylesheet" />
<link href="./assets/css/prism-lite.css" rel="stylesheet" />
<script src="https://code.iconify.design/1/1.0.3/iconify.min.js"></script>
<meta name="description" content="Optuna is an automatic hyperparameter optimization software framework, particularly designed for machine learning.">
<meta property="og:site_name" content="Optuna">
<meta property="og:title" content="Optuna - A hyperparameter optimization framework">
<meta property="og:description" content="Optuna is an automatic hyperparameter optimization software framework, particularly designed for machine learning. It features an imperative, define-by-run style user API. ">
<meta property="og:type" content="website">
<meta property="og:url" content="https://optuna.org/">
<meta property="og:image" content="https://optuna.org/assets/img/optuna-logo.png">
<meta name="twitter:card" content="summary">
<meta name="twitter:site" content="https://optuna.org/">
<meta name="twitter:image" content="https://optuna.org/assets/img/optuna-logo.png">
<!-- Fonts and icons -->
<link href='https://fonts.googleapis.com/css?family=Montserrat:400,300,700|Work+Sans|Material+Icons' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">
<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>
</head>
<body>
<!-- <nav class="navbar navbar-expand-lg fixed-top navbar-transparent" color-on-scroll="450"> -->
<nav class="navbar navbar-expand-lg fixed-top" color-on-scroll="450">
<div class="container">
<div class="navbar-translate">
<a class="navbar-brand" href="https://optuna.org/"><h1 style="font-size:32px;margin:0;padding:0; font-weight:300;"><img src="./assets/img/optuna-logo.png" id="header_logo" style="width:230px; margin-top:-10px;" alt="Optuna Logo"></h1></a>
<button class="navbar-toggler navbar-toggler-right navbar-burger" type="button" data-toggle="collapse" data-target="#navbarToggler" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-bar"></span>
<span class="navbar-toggler-bar"></span>
<span class="navbar-toggler-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse" id="navbarToggler">
<ul class="navbar-nav ml-auto">
<li class="nav-item"><a href="#key_features" class="header_link"> Key Features</a></li>
<li class="nav-item"><a href="#code_examples" class="header_link"> Code Examples</a></li>
<li class="nav-item"><a href="#installation" class="header_link"> Installation</a></li>
<li class="nav-item"><a href="#blog" class="header_link"> Blog</a></li>
<li class="nav-item"><a href="#video" class="header_link"> Videos</a></li>
<li class="nav-item"><a href="#paper" class="header_link"> Paper</a></li>
</ul>
</div>
</div>
</nav>
<div class="wrapper">
<div class="page-header page-header-small" style="background-image: url('./assets/img/bg.jpg');">
<div class="container">
<div class="filter"></div>
<div class="motto">
<h1 style="padding-top:55px; font-weight:bold; font-size:3em;">Optimize Your Optimization</h1>
<p style="padding-top:10px;">An open source hyperparameter optimization framework to automate hyperparameter search</p>
</div>
</div>
</div>
<div class="main">
<div class="section" style="padding:0px;">
<div class="container">
<!-- Key Features -->
<div class="row">
<div class="col-md-12 ml-auto mr-auto">
<h2 class="text-center" id="key_features" style="padding-top:80px; margin-top:-20px; padding-bottom:20px; font-weight:bold; color:#333333;">Key Features</h2>
<div class="row">
<div class="col-md-4">
<div class="card card-blog card-top-shadow">
<div class="card-body" style="min-height: 250px;">
<h2 class="card-category text-center" style="font-weight:bold; font-size: 18px;">Eager search spaces</h2>
<div class="card-image text-center">
<img class="img img-raised" src="https://icongr.am/fontawesome/expand.svg?color=123692" style="width:17%; margin:5px 0; padding: 5px 0;">
</div>
<p class="card-description text-left" style="margin-top:10px;">
Automated search for optimal hyperparameters using Python conditionals, loops, and syntax
</p>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card card-blog card-top-shadow">
<div class="card-body" style="min-height: 250px;">
<h2 class="card-category text-center" style="font-weight:bold; font-size: 18px;">State-of-the-art algorithms</h2>
<div class="card-image text-center">
<img class="img img-raised" src="https://icongr.am/fontawesome/rocket.svg?color=123692" style="width:17%; margin:5px 0; padding: 5px 0;">
</div>
<p class="card-description text-left" style="margin-top:10px;">
Efficiently search large spaces and prune unpromising trials for faster results
</p>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card card-blog card-top-shadow">
<div class="card-body" style="min-height: 250px;">
<h2 class="card-category text-center" style="font-weight:bold; font-size: 18px;">Easy parallelization</h2>
<div class="card-image text-center">
<img class="img img-raised" src="./assets/img/large_scale.png" style="width:20%; margin:5px 0;">
</div>
<p class="card-description text-left" style="margin-top:10px;">
Parallelize hyperparameter searches over multiple threads or processes without modifying code
</p>
</div>
</div>
</div>
</div> <!-- end of row -->
</div> <!-- end of col-12 -->
<!-- external links (top) -->
<div class="col-md-12 ml-auto mr-auto">
<ul id="icons-links" class="text-center" style="margin-top:60px;">
<a href="https://github.com/optuna/optuna" onClick="gtag('event', 'out', {'event_category': 'index.html','event_label': 'github-top'});"><button class="btn btn-primary"><img src="https://icongr.am/octicons/mark-github.svg?size=30&color=ffffff"> Github<div class="ripple-container"></div></button></a>
<a href="https://optuna.readthedocs.io/en/stable/tutorial/index.html" onClick="gtag('event', 'out', {'event_category': 'index.html','event_label': 'tutorials-top'});"><button class="btn btn-primary"><img src="https://icongr.am/octicons/code.svg?size=30&color=ffffff"> Tutorials<div class="ripple-container"></div></button></a>
<a href="https://twitter.com/OptunaAutoML" onClick="gtag('event', 'out', {'event_category': 'index.html','event_label': 'twitter-top'});"><button class="btn btn-primary"><img src="./assets/img/twitter-logo-circle.svg" height="30"> Twitter<div class="ripple-container"></div></button></a>
<a href="https://gitter.im/optuna/optuna" onClick="gtag('event', 'out', {'event_category': 'index.html','event_label': 'gitter-top'});"><button class="btn btn-primary"><img src="https://icongr.am/octicons/comment-discussion.svg?size=30&color=ffffff"> Gitter<div class="ripple-container"></div></button></a>
</ul>
</div>
</div> <!-- end of row -->
<!-- Code Examples -->
<div class="row">
<div class="col-md-12 ml-auto mr-auto" id="code-examples">
<h2 class="text-center" id="code_examples" style="padding-top:80px; margin-top:-20px; padding-bottom:20px; font-weight:bold; color:#333333;">Code Examples</h2>
<div class="profile-tabs" style="margin:0px;">
<div class="nav-tabs-navigation col-md-12 ml-auto mr-auto">
<div class="nav-tabs-wrapper">
<ul id="tabs" class="nav nav-tabs" role="tablist">
<li class="nav-item ">
<a class="nav-link nav-link-narrow active" href="#code_quickstart" data-toggle="tab" role="tab" aria-selected="true"><img class="tablist-icon" src="./assets/img/favicon.ico" height="20"> <span class="tablist-text">Quick Start</span></a>
</li>
<li class="nav-item ">
<a class="nav-link nav-link-narrow" href="#code_PyTorch" data-toggle="tab" role="tab" aria-selected="false"><span class="iconify tablist-icon" data-icon="logos-pytorch" data-inline="false" height="20"></span> <span class="tablist-text">PyTorch</span></a>
</li>
<li class="nav-item ">
<a class="nav-link nav-link-narrow" href="#code_chainer" data-toggle="tab" role="tab" aria-selected="false"><img class="tablist-icon" src="./assets/img/chainer_icon_red.png" height="20"> <span class="tablist-text">Chainer</span></a>
</li>
<li class="nav-item">
<a class="nav-link nav-link-narrow" href="#code_tensorflow" data-toggle="tab" role="tab" aria-selected="false"><img class="tablist-icon" src="./assets/img/tensorflow_icon.png" height="20"> <span class="tablist-text">TensorFlow</span></a>
</li>
<li class="nav-item">
<a class="nav-link nav-link-narrow" href="#code_Keras" data-toggle="tab" role="tab" aria-selected="false"><span class="iconify tablist-icon" data-icon="ant-design:code-filled" data-inline="false" height="20" style="color:#CA0003"></span> <span class="tablist-text">Keras</span></a>
</li>
<li class="nav-item">
<a class="nav-link nav-link-narrow" href="#code_MXNet" data-toggle="tab" role="tab" aria-selected="false"><img class="tablist-icon" src="./assets/img/mxnet-icon.png" height="20"> <span class="tablist-text">MXNet</span></a>
</li>
<li class="nav-item">
<a class="nav-link nav-link-narrow" href="#code_ScikitLearn" data-toggle="tab" role="tab" aria-selected="false"><img class="tablist-icon" src="./assets/img/favicon-sklearn.ico" height="20"> <span class="tablist-text">Scikit-Learn</span></a>
</li>
<li class="nav-item">
<a class="nav-link nav-link-narrow" href="#code_XGBoost" data-toggle="tab" role="tab" aria-selected="false"> <img class="tablist-icon" src="./assets/img/xgboost-logo.png" height="20" alt="XGBoost"> </a>
</li>
<li class="nav-item">
<a class="nav-link nav-link-narrow" href="#code_LightGBM" data-toggle="tab" role="tab" aria-selected="false"><span class="iconify tablist-icon" data-icon="ant-design:code-outlined" data-inline="false" height="20"></span> <span class="tablist-text">LightGBM</span></a>
</li>
<li class="nav-item">
<a class="nav-link nav-link-narrow" href="#code_other" data-toggle="tab" role="tab" aria-selected="false"><span class="iconify tablist-icon" data-icon="ant-design:code-filled" data-inline="false" height="20"></span> <span class="tablist-text">Other</span></a>
</li>
</ul>
</div>
</div>
<div class="tab-content col-md-9 ml-auto mr-auto" style="padding-left:3px; padding-right:3px;">
<div class="tab-pane active" id="code_quickstart" role="tabpanel">
<div class="row">
<div class="col-md-12">
<p class="space-top text-left" style="padding-top:0px;">
<p class="space-top" style="margin-top:0px;">A simple optimization problem:</p>
<ol>
<li>Define <code>objective</code> function to be optimized. Let's minimize <code>(x - 2)^2</code></li>
<li>Suggest hyperparameter values using <code>trial</code> object. Here, a float value of <code>x</code> is suggested from <code>-10</code> to <code>10</code></li>
<li>Create a <code>study</code> object and invoke the <code>optimize</code> method over 100 trials</li>
</ol>
<pre><code class="language-python">import optuna
def objective(trial):
x = trial.suggest_uniform('x', -10, 10)
return (x - 2) ** 2
study = optuna.create_study()
study.optimize(objective, n_trials=100)
study.best_params # E.g. {'x': 2.002108042}</code></pre>
<p class="space-top" style="margin-top:0px;">
<a href="http://colab.research.google.com/github/optuna/optuna/blob/master/examples/quickstart.ipynb" onClick="gtag('event', 'out', {'event_category': 'index.html','event_label':'quickstart-colab'});"><img src="https://colab.research.google.com/assets/colab-badge.svg" width="150px" /></a></p>
</p>
</div>
</div>
</div>
<div class="tab-pane" id="code_PyTorch" role="tabpanel">
<div class="row">
<div class="col-md-12">
<p class="space-top text-left" style="padding-top:0px;">
You can optimize PyTorch hyperparameters, such as the number of layers and the number of hidden nodes in each layer, in three steps:<br/>
<ol>
<li>Wrap model training with an <code>objective</code> function and return accuracy</li>
<li>Suggest hyperparameters using a <code>trial</code> object</li>
<li>Create a <code>study</code> object and execute the optimization</li>
</ol>
<pre><code class="language-python">import torch
import optuna
# 1. Define an objective function to be maximized.
def objective(trial):
# 2. Suggest values of the hyperparameters using a trial object.
n_layers = trial.suggest_int('n_layers', 1, 3)
layers = []
in_features = 28 * 28
for i in range(n_layers):
out_features = trial.suggest_int('n_units_l{}'.format(i), 4, 128)
layers.append(torch.nn.Linear(in_features, out_features))
layers.append(torch.nn.ReLU())
in_features = out_features
layers.append(torch.nn.Linear(in_features, 10))
layers.append(torch.nn.LogSoftmax(dim=1))
model = torch.nn.Sequential(*layers).to(torch.device('cpu'))
...
return accuracy
# 3. Create a study object and optimize the objective function.
study = optuna.create_study(direction='maximize')
study.optimize(objective, n_trials=100)</code></pre>
<a href="https://github.com/optuna/optuna-examples/blob/main/pytorch/pytorch_simple.py" onClick="gtag('event', 'out', {'event_category': 'index.html','event_label': 'pytorch-example'});"><button class="btn btn-light" style="margin-top:10px; padding:5px 10px; font-size:15px;"><img src="https://icongr.am/octicons/chevron-right.svg?size=15&color=ffffff"> See full example on Github</button></a>
</p>
</div>
</div>
</div>
<div class="tab-pane" id="code_chainer" role="tabpanel">
<div class="row">
<div class="col-md-12">
<p class="space-top text-left" style="padding-top:0px;">
You can optimize Chainer hyperparameters, such as the number of layers and the number of hidden nodes in each layer, in three steps:<br/>
<ol>
<li>Wrap model training with an <code>objective</code> function and return accuracy</li>
<li>Suggest hyperparameters using a <code>trial</code> object</li>
<li>Create a <code>study</code> object and execute the optimization</li>
</ol>
<pre><code class="language-python">import chainer
import optuna
# 1. Define an objective function to be maximized.
def objective(trial):
# 2. Suggest values of the hyperparameters using a trial object.
n_layers = trial.suggest_int('n_layers', 1, 3)
layers = []
for i in range(n_layers):
n_units = int(trial.suggest_loguniform('n_units_l{}'.format(i), 4, 128))
layers.append(L.Linear(None, n_units))
layers.append(F.relu)
layers.append(L.Linear(None, 10))
model = L.Classifier(chainer.Sequential(*layers))
...
return accuracy
# 3. Create a study object and optimize the objective function.
study = optuna.create_study(direction='maximize')
study.optimize(objective, n_trials=100)</code></pre>
<a href="https://github.com/optuna/optuna-examples/blob/main/chainer/chainer_simple.py" onClick="gtag('event', 'out', {'event_category': 'index.html','event_label': 'chainer-example'});"><button class="btn btn-light" style="margin-top:10px; padding:5px 10px; font-size:15px;"><img src="https://icongr.am/octicons/chevron-right.svg?size=15&color=ffffff"> See full example on Github</button></a>
</p>
</div>
</div>
</div>
<div class="tab-pane" id="code_tensorflow" role="tabpanel">
<div class="row">
<div class="col-md-12">
<p class="space-top text-left" style="padding-top:0px;">
You can optimize TensorFlow hyperparameters, such as the number of layers and the number of hidden nodes in each layer, in three steps:<br/>
<ol>
<li>Wrap model training with an <code>objective</code> function and return accuracy</li>
<li>Suggest hyperparameters using a <code>trial</code> object</li>
<li>Create a <code>study</code> object and execute the optimization</li>
</ol>
<pre><code class="language-python">import tensorflow as tf
import optuna
# 1. Define an objective function to be maximized.
def objective(trial):
# 2. Suggest values of the hyperparameters using a trial object.
n_layers = trial.suggest_int('n_layers', 1, 3)
model = tf.keras.Sequential()
model.add(tf.keras.layers.Flatten())
for i in range(n_layers):
num_hidden = int(trial.suggest_loguniform('n_units_l{}'.format(i), 4, 128))
model.add(tf.keras.layers.Dense(num_hidden, activation='relu'))
model.add(tf.keras.layers.Dense(CLASSES))
...
return accuracy
# 3. Create a study object and optimize the objective function.
study = optuna.create_study(direction='maximize')
study.optimize(objective, n_trials=100)</code></pre>
<a href="https://github.com/optuna/optuna-examples/blob/main/tensorflow/tensorflow_eager_simple.py" onClick="gtag('event', 'out', {'event_category': 'index.html','event_label': 'tensorflow-eager-example'});"><button class="btn btn-light" style="margin-top:10px; padding:5px 10px; font-size:15px;"><img src="https://icongr.am/octicons/chevron-right.svg?size=15&color=ffffff"> See full example on Github</button></a>
</p>
</div>
</div>
</div>
<div class="tab-pane" id="code_Keras" role="tabpanel">
<div class="row">
<div class="col-md-12">
<p class="space-top text-left" style="padding-top:0px;">
You can optimize Keras hyperparameters, such as the number of filters and kernel size, in three steps:<br/>
<ol>
<li>Wrap model training with an <code>objective</code> function and return accuracy</li>
<li>Suggest hyperparameters using a <code>trial</code> object</li>
<li>Create a <code>study</code> object and execute the optimization</li>
</ol>
<pre><code class="language-python">import keras
import optuna
# 1. Define an objective function to be maximized.
def objective(trial):
model = Sequential()
# 2. Suggest values of the hyperparameters using a trial object.
model.add(
Conv2D(filters=trial.suggest_categorical('filters', [32, 64]),
kernel_size=trial.suggest_categorical('kernel_size', [3, 5]),
strides=trial.suggest_categorical('strides', [1, 2]),
activation=trial.suggest_categorical('activation', ['relu', 'linear']),
input_shape=input_shape))
model.add(Flatten())
model.add(Dense(CLASSES, activation='softmax'))
# We compile our model with a sampled learning rate.
lr = trial.suggest_loguniform('lr', 1e-5, 1e-1)
model.compile(loss='sparse_categorical_crossentropy', optimizer=RMSprop(lr=lr), metrics=['accuracy'])
...
return accuracy
# 3. Create a study object and optimize the objective function.
study = optuna.create_study(direction='maximize')
study.optimize(objective, n_trials=100)</code></pre>
<a href="https://github.com/optuna/optuna-examples/blob/main/keras/keras_simple.py" onClick="gtag('event', 'out', {'event_category': 'index.html','event_label': 'keras-example'});"><button class="btn btn-light" style="margin-top:10px; padding:5px 10px; font-size:15px;"><img src="https://icongr.am/octicons/chevron-right.svg?size=15&color=ffffff"> See full example on Github</button></a>
</p>
</div>
</div>
</div>
<div class="tab-pane" id="code_MXNet" role="tabpanel">
<div class="row">
<div class="col-md-12">
<p class="space-top text-left" style="padding-top:0px;">
You can optimize MXNet hyperparameters, such as the number of layers and the number of hidden nodes in each layer, in three steps:<br/>
<ol>
<li>Wrap model training with an <code>objective</code> function and return accuracy</li>
<li>Suggest hyperparameters using a <code>trial</code> object</li>
<li>Create a <code>study</code> object and execute the optimization</li>
</ol>
<pre><code class="language-python">import mxnet as mx
import optuna
# 1. Define an objective function to be maximized.
def objective(trial):
# 2. Suggest values of the hyperparameters using a trial object.
n_layers = trial.suggest_int('n_layers', 1, 3)
data = mx.symbol.Variable('data')
data = mx.sym.flatten(data=data)
for i in range(n_layers):
num_hidden = int(trial.suggest_loguniform('n_units_l{}'.format(i), 4, 128))
data = mx.symbol.FullyConnected(data=data, num_hidden=num_hidden)
data = mx.symbol.Activation(data=data, act_type="relu")
data = mx.symbol.FullyConnected(data=data, num_hidden=10)
mlp = mx.symbol.SoftmaxOutput(data=data, name="softmax")
...
return accuracy
# 3. Create a study object and optimize the objective function.
study = optuna.create_study(direction='maximize')
study.optimize(objective, n_trials=100)</code></pre>
<a href="https://github.com/optuna/optuna-examples/blob/main/mxnet/mxnet_simple.py" onClick="gtag('event', 'out', {'event_category': 'index.html','event_label': 'mxnet-example'});"><button class="btn btn-light" style="margin-top:10px; padding:5px 10px; font-size:15px;"><img src="https://icongr.am/octicons/chevron-right.svg?size=15&color=ffffff"> See full example on Github</button></a>
</p>
</div>
</div>
</div>
<div class="tab-pane" id="code_ScikitLearn" role="tabpanel">
<div class="row">
<div class="col-md-12">
<p class="space-top text-left" style="padding-top:0px;">
You can optimize Scikit-Learn hyperparameters, such as the <code>C</code> parameter of <code>SVC</code> and the <code>max_depth</code> of the <code>RandomForestClassifier</code>, in three steps:<br/>
<ol>
<li>Wrap model training with an <code>objective</code> function and return accuracy</li>
<li>Suggest hyperparameters using a <code>trial</code> object</li>
<li>Create a <code>study</code> object and execute the optimization</li>
</ol>
<pre><code class="language-python">import sklearn
import optuna
# 1. Define an objective function to be maximized.
def objective(trial):
# 2. Suggest values for the hyperparameters using a trial object.
classifier_name = trial.suggest_categorical('classifier', ['SVC', 'RandomForest'])
if classifier_name == 'SVC':
svc_c = trial.suggest_loguniform('svc_c', 1e-10, 1e10)
classifier_obj = sklearn.svm.SVC(C=svc_c, gamma='auto')
else:
rf_max_depth = int(trial.suggest_loguniform('rf_max_depth', 2, 32))
classifier_obj = sklearn.ensemble.RandomForestClassifier(max_depth=rf_max_depth, n_estimators=10)
...
return accuracy
# 3. Create a study object and optimize the objective function.
study = optuna.create_study(direction='maximize')
study.optimize(objective, n_trials=100)</code></pre>
<a href="https://github.com/optuna/optuna-examples/blob/main/sklearn/sklearn_simple.py" onClick="gtag('event', 'out', {'event_category': 'index.html','event_label': 'sklearn-example'});"><button class="btn btn-light" style="margin-top:10px; padding:5px 10px; font-size:15px;"><img src="https://icongr.am/octicons/chevron-right.svg?size=15&color=ffffff"> See full example on Github</button></a>
</p>
</div>
</div>
</div>
<div class="tab-pane" id="code_XGBoost" role="tabpanel">
<div class="row">
<div class="col-md-12">
<p class="space-top text-left" style="padding-top:0px;">
You can optimize XGBoost hyperparameters, such as the booster type and alpha, in three steps:<br/>
<ol>
<li>Wrap model training with an <code>objective</code> function and return accuracy</li>
<li>Suggest hyperparameters using a <code>trial</code> object</li>
<li>Create a <code>study</code> object and execute the optimization</li>
</ol>
<pre><code class="language-python">import xgboost as xgb
import optuna
# 1. Define an objective function to be maximized.
def objective(trial):
...
# 2. Suggest values of the hyperparameters using a trial object.
param = {
'silent': 1,
'objective': 'binary:logistic',
'booster': trial.suggest_categorical('booster', ['gbtree', 'gblinear', 'dart']),
'lambda': trial.suggest_loguniform('lambda', 1e-8, 1.0),
'alpha': trial.suggest_loguniform('alpha', 1e-8, 1.0)
}
bst = xgb.train(param, dtrain)
...
return accuracy
# 3. Create a study object and optimize the objective function.
study = optuna.create_study(direction='maximize')
study.optimize(objective, n_trials=100)</code></pre>
<a href="https://github.com/optuna/optuna-examples/blob/main/xgboost/xgboost_simple.py" onClick="gtag('event', 'out', {'event_category': 'index.html','event_label': 'xgboost-example'});"><button class="btn btn-light" style="margin-top:10px; padding:5px 10px; font-size:15px;"><img src="https://icongr.am/octicons/chevron-right.svg?size=15&color=ffffff"> See full example on Github</button></a>
</p>
</div>
</div>
</div>
<div class="tab-pane" id="code_LightGBM" role="tabpanel">
<div class="row">
<div class="col-md-12">
<p class="space-top text-left" style="padding-top:0px;">
You can optimize LightGBM hyperparameters, such as boosting type and the number of leaves, in three steps:<br/>
<ol>
<li>Wrap model training with an <code>objective</code> function and return accuracy</li>
<li>Suggest hyperparameters using a <code>trial</code> object</li>
<li>Create a <code>study</code> object and execute the optimization</li>
</ol>
<pre><code class="language-python">import lightgbm as lgb
import optuna
# 1. Define an objective function to be maximized.
def objective(trial):
...
# 2. Suggest values of the hyperparameters using a trial object.
param = {
'objective': 'binary',
'metric': 'binary_logloss',
'verbosity': -1,
'boosting_type': 'gbdt',
'lambda_l1': trial.suggest_loguniform('lambda_l1', 1e-8, 10.0),
'lambda_l2': trial.suggest_loguniform('lambda_l2', 1e-8, 10.0),
'num_leaves': trial.suggest_int('num_leaves', 2, 256),
'feature_fraction': trial.suggest_uniform('feature_fraction', 0.4, 1.0),
'bagging_fraction': trial.suggest_uniform('bagging_fraction', 0.4, 1.0),
'bagging_freq': trial.suggest_int('bagging_freq', 1, 7),
'min_child_samples': trial.suggest_int('min_child_samples', 5, 100),
}
gbm = lgb.train(param, dtrain)
...
return accuracy
# 3. Create a study object and optimize the objective function.
study = optuna.create_study(direction='maximize')
study.optimize(objective, n_trials=100)</code></pre>
<a href="https://github.com/optuna/optuna-examples/blob/main/lightgbm/lightgbm_simple.py" onClick="gtag('event', 'out', {'event_category': 'index.html','event_label': 'lightgbm-example'});"><button class="btn btn-light" style="margin-top:10px; padding:5px 10px; font-size:15px;"><img src="https://icongr.am/octicons/chevron-right.svg?size=15&color=ffffff"> See full example on Github</button></a>
</p>
</div>
</div>
</div>
<div class="tab-pane" id="code_other" role="tabpanel">
<div class="row">
<div class="col-md-12">
<p class="space-top text-left" style="padding-top:0px;">
Check more examples including PyTorch Ignite, Dask-ML and MLFlow at our Github repository.<br/>
It also provides the visualization demo as follows:
<pre>
<code class="language-python">from optuna.visualization import plot_intermediate_values
...
plot_intermediate_values(study)</code></pre>
<div class="text-center">
<img src="assets/img/intermediate-values-graph.png" width="60%" class="card-top-shadow text-center">
</div>
</p>
<a href="https://github.com/optuna/optuna-examples/blob/main/README.md" onClick="gtag('event', 'out', {'event_category': 'index.html','event_label': 'more-examples'});"><button class="btn btn-light" style="margin-top:10px; padding:5px 10px; font-size:15px;"><img src="https://icongr.am/octicons/chevron-right.svg?size=15&color=ffffff"> See more examples on Github</button></a>
</div>
</div>
</div>
</div> <!-- end of tab-content-->
</div> <!-- end of profile-tabs -->
</div> <!-- end of col -->
</div> <!-- end of row -->
<div class="row">
<div class="col-md-12 ml-auto mr-auto">
<h2 class="text-center" id="installation" style="padding-top:80px; margin-top:-20px; padding-bottom:20px; font-weight:bold; color:#333333;">Installation</h2>
<div class="row">
<div class="col-md-9 ml-auto mr-auto">
<p class="text-left" style="padding-top:0px;">
Optuna can be installed with pip. Python 3.5 or newer is supported.<br>
</p>
<p class="text-center">
<pre><code class="language-bash">% pip install optuna</code></pre>
</p>
<a href="https://optuna.readthedocs.io/en/stable/installation.html" onClick="gtag('event', 'out', {'event_category': 'index.html','event_label': 'installation'});"><button class="btn btn-ligtht" style="margin-top:10px; padding:5px 10px; font-size:15px;"><img src="https://icongr.am/octicons/chevron-right.svg?size=15&color=ffffff"> Details</button></a>
</div>
</div>
</div>
</div> <!-- end of row -->
<!-- external links (top) -->
<ul id="icons-links" class="text-center" style="margin-top:60px;">
<a href="https://github.com/optuna/optuna" onClick="gtag('event', 'out', {'event_category': 'index.html','event_label': 'github-middle'});"><button class="btn btn-primary"><img src="https://icongr.am/octicons/mark-github.svg?size=30&color=ffffff"> Github<div class="ripple-container"></div></button></a>
<a href="https://optuna.readthedocs.io/en/stable/tutorial/index.html" onClick="gtag('event', 'out', {'event_category': 'index.html','event_label': 'tutorials-middle'});"><button class="btn btn-primary"><img src="https://icongr.am/octicons/code.svg?size=30&color=ffffff"> Tutorials<div class="ripple-container"></div></button></a>
<a href="https://twitter.com/OptunaAutoML" onClick="gtag('event', 'out', {'event_category': 'index.html','event_label': 'twitter-middle'});"><button class="btn btn-primary"><img src="./assets/img/twitter-logo-circle.svg" height="30"> Twitter<div class="ripple-container"></div></button></a>
<a href="https://gitter.im/optuna/optuna" onClick="gtag('event', 'out', {'event_category': 'index.html','event_label':'gitter-middle'});"><button class="btn btn-primary"><img src="https://icongr.am/octicons/comment-discussion.svg?size=30&color=ffffff"> Gitter<div class="ripple-container"></div></button></a>
</ul>
<div class="row" style="margin-top:0px;">
<div class="col-md-12 ml-auto mr-auto">
<div class="row">
<div class="col-md-12 ml-auto mr-auto text-center">
<h2 id="blog" class="text-center" style="padding-top:80px; margin-top:-20px; padding-bottom:20px; font-weight:bold; color:#333333;">News</h2>
<div class="row">
<div class="col-md-6 ml-auto mr-auto" style="margin-bottom:10px;">
<blockquote class="twitter-tweet"><p lang="en" dir="ltr">We are pleased to announce Optuna will participate in the Google Summer of Code 2020! We are looking for students with passion to improve hyperparameter optimization together. Check out project ideas here: <a href="https://t.co/AujDvmyBf1">https://t.co/AujDvmyBf1</a> <a href="https://twitter.com/hashtag/gsoc?src=hash&ref_src=twsrc%5Etfw" onClick="gtag('event', 'out', {'event_category': 'index.html','event_label': 'twitter-tweet-gsoc'});">#gsoc</a></p>— OptunaAutoML (@OptunaAutoML) <a href="https://twitter.com/OptunaAutoML/status/1235453126406066182?ref_src=twsrc%5Etfw" onClick="gtag('event', 'out', {'event_category': 'index.html','event_label': 'twitter-tweet-gsoc'});">March 5, 2020</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
</div>
<div class="col-md-6 ml-auto mr-auto" style="margin-bottom:10px;">
<blockquote class="twitter-tweet"><p lang="en" dir="ltr">Released <a href="https://twitter.com/hashtag/Optuna?src=hash&ref_src=twsrc%5Etfw" onClick="gtag('event', 'out', {'event_category': 'index.html','event_label': 'twitter-tweet-v1.2.0'});">#Optuna</a> v1.2.0! New features including queuing of trials with user specified predetermined parameter values and an experimental grid search sampler. A bug in one of our parameter suggestion APIs was fixed. <a href="https://t.co/hi3uHWGLPE" onClick="gtag('event', 'out', {'event_category': 'index.html','event_label': 'twitter-tweet-v1.2.0'});">https://t.co/hi3uHWGLPE</a></p>— OptunaAutoML (@OptunaAutoML) <a href="https://twitter.com/OptunaAutoML/status/1235446413531557888?ref_src=twsrc%5Etfw" onClick="gtag('event', 'out', {'event_category': 'index.html','event_label': 'twitter-tweet-v1.2.0'});">March 5, 2020</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row" style="margin-top:0px;">
<div class="col-md-12 ml-auto mr-auto">
<div class="row">
<div class="col-md-12 ml-auto mr-auto text-center">
<h2 id="blog" class="text-center" style="padding-top:80px; margin-top:-20px; padding-bottom:20px; font-weight:bold; color:#333333;">Blog</h2>
<div class="row">
<div class="col-md-6 ml-auto mr-auto" style="margin-bottom:10px;">
<a href="https://medium.com/optuna/optuna-v1-86192cd09be5" onClick="gtag('event', 'out', {'event_category': 'index.html','event_label': 'blog-v1'});">
<img src="assets/img/optuna-blog-v1-560x315.png" alt="Announcing Optuna 1.0" class="card-top-shadow" style="width: 560px; height: auto; max-width:100%; max-height:100%;"></a>
</div>
<div class="col-md-6 ml-auto mr-auto" style="margin-bottom:10px;">
<a href="https://medium.com/optuna/lightgbm-tuner-new-optuna-integration-for-hyperparameter-optimization-8b7095e99258" onClick="gtag('event', 'out', {'event_category': 'index.html','event_label': 'blog-lightgbm-tuner'});">
<img src="assets/img/optuna-blog-lightgbm-tuner-560x315.png" alt="LightGBM Tuner: New Optuna Integration for Hyperparameter Optimization" class="card-top-shadow" style="width: 560px; height: auto; max-width:100%; max-height:100%;"></a>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12 ml-auto mr-auto text-center">
<div class="row">
<div class="col-md-6 ml-auto mr-auto" style="margin-bottom:10px;">
<a href="https://medium.com/optuna/optuna-supports-hyperband-93b0cae1a137" onClick="gtag('event', 'out', {'event_category': 'index.html','event_label': 'blog-hyperband'});">
<img src="assets/img/optuna-blog-hyperband-560x315.png" alt="How We Implement Hyperband in Optuna" class="card-top-shadow" style="width: 560px; height: auto; max-width:100%; max-height:100%;"></a>
</div>
<div class="col-md-6 ml-auto mr-auto" style="margin-bottom:10px;">
<a href="https://medium.com/optuna/kurobako-a2e3f7b760c7" onClick="gtag('event', 'out', {'event_category': 'index.html','event_label': 'blog-kurobako'});">
<img src="assets/img/optuna-blog-kurobako-560x315.png" alt="Introduction to Kurobako: A Benchmark Tool for Hyperparameter Optimization Algorithms" class="card-top-shadow" style="width: 560px; height: auto; max-width:100%; max-height:100%;"></a>
</div>
</div>
</div>
</div>
<h2 id="video" class="text-center" style="padding-top:80px; margin-top:-20px; padding-bottom:20px; font-weight:bold; color:#333333;">Videos</h2>
<div class="row" style="margin-top:0px;">
<div class="col-md-6 ml-auto mr-auto text-center youtube">
<iframe width="560" height="315" src="https://www.youtube.com/embed/J_aymk4YXhg" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>
<div class="col-md-6 ml-auto mr-auto text-center youtube">
<iframe width="560" height="315" src="https://www.youtube.com/embed/-UeC4MR3PHM" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>
</div>
<div class="row" style="margin-top:0px;">
<div class="col-md-12 ml-auto mr-auto text-center">
<h2 id="paper" class="text-center" style="padding-top:80px; margin-top:-20px; padding-bottom:20px; font-weight:bold; color:#333333;">Paper</h2>
<p class="text-left">If you use Optuna in a scientific publication, please use the following citation:</p>
<pre class="prettyprint_pub" style="margin-top:0px; margin-bottom:10px;">Takuya Akiba, Shotaro Sano, Toshihiko Yanase, Takeru Ohta,and Masanori Koyama. 2019.
Optuna: A Next-generation Hyperparameter Optimization Framework. In KDD.</pre>
<a href="https://dl.acm.org/citation.cfm?id=3330701" class="btn btn-default btn-round" onClick="gtag('event', 'out', {'event_category': 'index.html','event_label': 'view-paper'});">View Paper</a>
<a href="https://arxiv.org/abs/1907.10902" class="btn btn-default btn-round" onClick="gtag('event', 'out', {'event_category': 'index.html','event_label': 'view-preprint'});">View Preprint</a>
<p class="text-left" style="margin-top:10px;">Bibtex entry:</p>
<pre class="prettyprint_pub" style="margin-top:0px; margin-bottom:0px;">@inproceedings{optuna_2019,
title={Optuna: A Next-generation Hyperparameter Optimization Framework},
author={Akiba, Takuya and Sano, Shotaro and Yanase, Toshihiko and Ohta, Takeru and Koyama, Masanori}
booktitle={Proceedings of the 25rd {ACM} {SIGKDD} International Conference on Knowledge Discovery and Data Mining},
year={2019}
}</pre>
</div>
</div>
</div>
</div>
<ul id="icons-links" class="text-center" style="margin-top:60px;">
<a href="https://github.com/optuna/optuna" onClick="gtag('event', 'out', {'event_category': 'index.html','event_label': 'github-bottom'});"><button class="btn btn-primary"><img src="https://icongr.am/octicons/mark-github.svg?size=30&color=ffffff"> Github<div class="ripple-container"></div></button></a>
<a href="https://optuna.readthedocs.io/en/stable/tutorial/index.html" onClick="gtag('event', 'out', {'event_category': 'index.html','event_label': 'tutorials-bottom'});"><button class="btn btn-primary"><img src="https://icongr.am/octicons/code.svg?size=30&color=ffffff"> Tutorials<div class="ripple-container"></div></button></a>
<a href="https://twitter.com/OptunaAutoML" onClick="gtag('event', 'out', {'event_category': 'index.html','event_label': 'twitter-bottom'});"><button class="btn btn-primary"><img src="./assets/img/twitter-logo-circle.svg" height="30"> Twitter<div class="ripple-container"></div></button></a>
<a href="https://gitter.im/optuna/optuna" onClick="gtag('event', 'out', {'event_category': 'index.html','event_label':'gitter-bottom'});"><button class="btn btn-primary"><img src="https://icongr.am/octicons/comment-discussion.svg?size=30&color=ffffff"> Gitter<div class="ripple-container"></div></button></a>
</ul>
</div> <!-- end of container -->
</div> <!-- end of section -->
</div> <!-- end of main -->
</div> <!-- end of wrapper -->
<footer class="footer footer-black">
<div class="container">
<div class="row" style="padding: 50px 0px 50px 0px;">
<nav class="footer-nav">
<ul>
<li><a href="https://www.preferred-networks.jp/en/" onClick="gtag('event', 'out', {'event_category': 'index.html','event_label':'pfn-footer'});">Preferred Networks, Inc.</a></li>
<li><a href="https://optuna.org/privacy" onClick="gtag('event', 'out', {'event_category': 'index.html','event_label':'privacy-footer'});">Privacy Policy.</a></li>
</ul>
</nav>
<div class="credits ml-auto">
<span class="copyright">
© 2018 Preferred Networks, Inc. All rights reserved.
<br> TensorFlow, the TensorFlow logo and any related marks are trademarks of Google Inc.
<br> Scikit-learn is distributed under <a href="https://github.com/scikit-learn/scikit-learn/blob/master/COPYING" onClick="gtag('event', 'out', {'event_category': 'index.html','event_label':'sklearn-license-footer'});">the new BSD license</a>.
<br> <a href="https://mxnet.apache.org/" onClick="gtag('event', 'out', {'event_category': 'index.html','event_label':'mxnet-footer'});">Apache MXNet</a> and the MXNet logo are either registered trademarks or trademarks of <br>the <a href="http://apache.org/" onClick="gtag('event', 'out', {'event_category': 'index.html','event_label':'asf-footer'});">Apache Software Foundation</a> in the United States and/or other countries.
<br> | Design: © 2017 Creative Tim
</span>
</div>
</div>
</div>
</footer>
</body>
<!-- Core JS Files -->
<script src="./assets/js/jquery-3.2.1.min.js" type="text/javascript"></script>
<script src="./assets/js/prism.js" type="text/javascript"></script>
<script src="./assets/js/jquery-ui-1.12.1.custom.min.js" type="text/javascript"></script>
<script src="./assets/js/popper.js" type="text/javascript"></script>
<script src="./assets/js/bootstrap.min.js" type="text/javascript"></script>
<!-- Plugin for Switches -->
<script src="./assets/js/bootstrap-switch.min.js"></script>
<!-- Paper Kit Initialization snd functons -->
<script src="./assets/js/paper-kit.js?v=2.1.0"></script>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-55135190-8"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-55135190-8');
</script>
<script>
$(document).ready(function() {
let searchParams = new URLSearchParams(window.location.search);
if (searchParams.has('code_example')) {
let tabName = searchParams.get('code_example');
// Activate tab specified by GET params.
$('.nav-tabs a[href="#' + tabName + '"]').tab('show');
}
});
</script>
</html>