我可以用SwarmPackagePy库绘制萤火虫算法的三维动画。在
我想用这个算法来优化高斯过程回归(GPR)中的超参数。为此,我将GPR的优化器定义为:
alh = SwarmPackagePy.fa(50, tf.easom_function, 0, 16, 2, 10, 1, 1, 1, 0.1, 0, 0.1)
animation3D(alh.get_agents(),tf.easom_function, 10,-10)
然后我在GPR中使用了这个优化器(alh),如下所示:
^{pr2}$但是,在运行python代码之后,我得到一个错误,如下所示:
ValueError: Unknown optimizer <SwarmPackagePy.fa.fa object at 0x0982A3B0>.
我做错事了吗?错误的原因是什么?在
谢谢你!在
正如sklearn的documentation所说,
optimizer
参数需要一个可调用的。但是,SwarmPackagePy.fa
不是可调用的。因为它既不是方法,也不是实现__call__
方法的类,从这里可以看出:https://github.com/SISDevelop/SwarmPackagePy/blob/master/SwarmPackagePy/fa.py
您可以在该文件中编写您自己的
__call__
方法,方法的签名与:相关问题 更多 >
编程相关推荐