You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems that the Ackley function is not working on Python 2.7 version
defackley_func(x):
ifnotnp.logical_and(x>=-32, x<=32).all():
raiseValueError('Input for Ackley function must be within [-32, 32].')
d=x.shape[1]
j= (-20.0*np.exp(-0.2*np.sqrt((1/d) * (x**2).sum(axis=1)))
-np.exp((1/d) *np.cos(2*np.pi*x).sum(axis=1))
+20.0+np.exp(1))
returnj
When given an input np.zeros([3,2]), most Python 3.X versions return something that isclose to np.zeros(3). But when ran against a Python 2.7.X version, we're getting [1.718, 1.718, 1.718]
The text was updated successfully, but these errors were encountered:
Turns out that you have to typecast the shape into float in order
to give you a float. Funny that I missed that difference between 2 and 3
Author: ljvmiranda921
Description
It seems that the Ackley function is not working on Python 2.7 version
When given an input
np.zeros([3,2])
, most Python 3.X versions return something thatisclose
tonp.zeros(3)
. But when ran against a Python 2.7.X version, we're getting[1.718, 1.718, 1.718]
The text was updated successfully, but these errors were encountered: