gpt4 book ai didi

python-3.x - 每个超参数的 Hyperopt 值列表

转载 作者:行者123 更新时间:2023-12-03 20:50:09 26 4
gpt4 key购买 nike

我正在尝试使用 Hyperopt在回归模型上,它的一个超参数是按变量定义的,需要作为列表传递。例如,如果我有一个包含 3 个自变量(不包括常量)的回归,我会通过 hyperparameter = [x, y, z] (其中 x, y, z 是浮点数)。
无论将其应用于哪个变量,此超参数的值都具有相同的界限。如果这个超参数应用于所有变量,我可以简单地使用 hp.uniform('hyperparameter', a, b) .我想要的搜索空间是 hp.uniform('hyperparameter', a, b) 的笛卡尔积长度n ,其中 n是回归中的变量数(因此,基本上, itertools.product(hp.uniform('hyperparameter', a, b), repeat = n) )
我想知道这在 Hyperopt 中是否可行。如果没有,欢迎对可能的优化器提出任何建议。

最佳答案

嗨,所以我用 optuna 实现了这个解决方案。 optuna 的优点是它会为所有单个值创建一个超空间,但以更智能的方式优化这些值,并且只使用一个超参数优化。例如,我使用 Batch-SIze、Learning-rate 和 Dropout-Rate 优化了一个神经网络:enter image description here
搜索空间比实际使用的值大得多。这可以节省大量时间,而不是网格搜索。
实现的伪代码是:

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
更详细的源代码访问 Optuna .它为我节省了很多时间,这是一个非常好的结果。

关于python-3.x - 每个超参数的 Hyperopt 值列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63252552/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com