Hyperasのfminが返す辞書のインデックスを値にする

HyperasでKerasのモデルのハイパーパラメータチューニングをしていた時、fminの返り値の辞書に含まれる結果が探索空間のインデックスで分かりにくい。

例えば探索するパラメータを

hp.choice('hidden1', [128, 1024])

このようにした時、チューニング結果が

{'hidden1': 0}

という辞書で帰ってくる。

インデックス0はhp.choiceの128を指し示すのだが、いちいち対応付けながら読み解くのが面倒くさい。

最初から探索空間の値を返すものがないかgithubを調べてみる。

https://github.com/hyperopt/hyperopt/blob/master/hyperopt/fmin.py

Returns

——-

argmin : dictionary If return_argmin is True returns trials.argmin which is a dictionary.

Otherwise this function returns the result of hyperopt.space_eval(space, trails.argmin) if there were successfull trails.

This object shares the same structure as the space passed.

If there were no successfull trails, it returns None.

return_argminの引数で調整できそう。

fmin(return_argmin=False)

{'hidden1': 128}

生の値が帰ってくるようになり満足。

コメント

タイトルとURLをコピーしました