Optuna: Trial XX failed because the number of the values 18 did not match the number of the objectives 1

パラメーターチューニングしていたら上記エラーが出ました。あまりにも基本的なミスだからかググっても出なかったので一応原因書いておきます。

理由は単純で、objective(trial)関数の返り値がfloatだと思っていたらstrになってしまっていました。普通にfloatにキャストしてあげれば解消しました。

I got the above error when I was tuning parameters. I did not find the cause of the error by Googling, probably because it is so basic.

The reason was simple: I thought the return value of the objective(trial) function was a float, but it was str. I solved the error by casting it to float as usual.

この記事が気に入ったらサポートをしてみませんか?