第19章ハイパーパラメータ最適化
19.1.2. Random Search19.1.2 ランダム探索
Random search is the first hyperparameter optimization algorithm we will consider. The main idea of random search is to independently sample from the configuration space until a predefined budget (e.g maximum number of iterations) is exhausted, and to return the best observed configuration. All evaluations can be executed independently in parallel (see Section 19.3), but here we use a sequential loop for simplicity.
英語のヒント
ランダム探索は、これから考える最初のハイパーパラメータ最適化のアルゴリズムである。ランダム探索の主な考え方は、あらかじめ決めた予算(たとえば反復の最大回数)を使い切るまで設定空間から独立に抜き出し、観測した中で最良の設定を返すことである。すべての評価は独立に並列に実行できる(19.3節を参照)が、ここでは簡単にするため逐次的なループを使う。
errors, values = [], []
num_iterations = 5
for i in range(num_iterations):
learning_rate = config_space["learning_rate"].rvs()
print(f"Trial {i}: learning_rate = {learning_rate}")
y = hpo_objective_softmax_classification({"learning_rate": learning_rate})
print(f" validation_error = {y}")
values.append(learning_rate)
errors.append(y) validation_error = 0.17070001363754272The best learning rate is then simply the one with the lowest validation error.
英語のヒント
最良の学習率は、単に検証誤差が最も小さいものである。
best_idx = np.argmin(errors)
print(f"optimal learning rate = {values[best_idx]}")optimal learning rate = 0.09844872561810249Due to its simplicity and generality, random search is one of the most frequently used HPO algorithms. It does not require any sophisticated implementation and can be applied to any configuration space as long as we can define some probability distribution for each hyperparameter.
英語のヒント
単純で汎用的なので、ランダム探索は最もよく使われるHPOのアルゴリズムの一つである。凝った実装は何も必要なく、各ハイパーパラメータに何らかの確率分布を定義できるかぎり、どんな設定空間にも当てはめられる。
Unfortunately random search also comes with a few shortcomings. First, it does not adapt the sampling distribution based on the previous observations it collected so far. Hence, it is equally likely to sample a poorly performing configuration than a better performing configuration. Second, the same amount of resources are spent for all configurations, even though some may show poor initial performance and are less likely to outperform previously seen configurations.
英語のヒント
残念ながら、ランダム探索にはいくつかの欠点もある。第一に、これまでに集めた過去の観測にもとづいてサンプリング分布を適応させない。したがって、性能の悪い設定を抜き出す見込みは、性能のよりよい設定を抜き出す見込みと同じである。第二に、最初の性能が悪く、以前に見た設定を上回る見込みが低いものがあっても、すべての設定に同じ量の資源が費やされる。
In the next sections we will look at more sample efficient hyperparameter optimization algorithms that overcome the shortcomings of random search by using a model to guide the search. We will also look at algorithms that automatically stop the evaluation process of poorly performing configurations to speed up the optimization process.
英語のヒント
次の節では、モデルを使って探索を導くことでランダム探索の欠点を克服する、標本効率のよりよいハイパーパラメータ最適化のアルゴリズムを見る。また、性能の悪い設定の評価の過程を自動的に止めて、最適化の過程を速めるアルゴリズムも見る。