简体   繁体   English

使用 Optuna 进行微调时使超参数加起来为 1

[英]Making hyperparameters add up to 1 when fine tuning using Optuna

I have a function which looks like this:我有一个看起来像这样的函数:

def fine_tuning(x,y,model1,model2,model3,trial):
   pred1 = model1.predict(x)
   pred2 = model2.predict(x)
   pred3 = model3.predict(x)
   
   h1 = trial.suggest_float('h1', 0.0001, 1, log = True)
   h2 = trial.suggest_float('h1', 0.0001, 1, log = True)
   h3 = trial.suggest_float('h1', 0.0001, 1, log = True)

   pred = pred1 * h1 + pred2 * h2 + pred3 * h3

   return mean_absolute_error(y, pred)

The problem with this function is that h1+h2+h3 != 1. How would I change this function in order to make the sum of the hyperparmaters = 1?此函数的问题在于 h1+h2+h3 != 1。我将如何更改此函数以使 hyperparmaters 的总和 = 1?

基本上,您正在寻找 h1、2、3 的狄利克雷分布。这是有关如何为 Optuna 实现该分布的指南: https ://optuna.readthedocs.io/en/latest/faq.html#how-do- i-suggest-variables-which-represent-the-proportion-that-are-in-accordance-with-dirichlet-distribution

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM