Alw*_*eft 5 mathematical-optimization python-3.x hyperopt
我尝试在回归模型上使用Hyperopt,以便为每个变量定义其超参数之一,并且需要作为列表传递。例如,如果我有一个包含 3 个自变量(不包括常量)的回归,我会通过hyperparameter = [x, y, z](其中x, y, z是浮点数)。
无论应用于哪个变量,该超参数的值都具有相同的界限。如果这个超参数应用于所有变量,我可以简单地使用hp.uniform('hyperparameter', a, b). 我希望搜索空间是hp.uniform('hyperparameter', a, b)length的笛卡尔积n,其中n是回归中变量的数量(所以,基本上,itertools.product(hp.uniform('hyperparameter', a, b), repeat = n))
我想知道这在 Hyperopt 中是否可行。如果没有,欢迎提供任何可能的优化器建议。
Sir*_*aum -1
你好,我用 optuna 实现了这个解决方案。optuna 的优点是它会为所有单独的值创建一个超空间,但以更智能的方式优化这些值,并且只使用一个超参数优化。例如,我使用 Batch-SIze、Learning-rate 和 Dropout-Rate 优化了一个神经网络:
搜索空间比实际使用的值大得多。这比网格搜索节省了很多时间。
实现的伪代码是:
def function(trial): #trials is the parameter of optuna, which selects the next hyperparameter
distribution = [0 , 1]
a = trials.uniform("a": distribution) #this is a uniform distribution
b = trials.uniform("a": distribution)
return (a*b)-b
#This above is the function which optuna tries to optimze/minimze
Run Code Online (Sandbox Code Playgroud)
有关更详细的源代码,请访问Optuna。这为我节省了很多时间,而且这是一个非常好的结果。
| 归档时间: |
|
| 查看次数: |
2865 次 |
| 最近记录: |