gkhayes / mlrose

Python package for implementing a number of Machine Learning, Randomized Optimization and SEarch algorithms.
https://mlrose.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
235 stars 243 forks source link

TypeError during Fitting #37

Closed negmos closed 4 years ago

negmos commented 4 years ago

I can't fit my data (it works on sklearn though). I keep getting this

AttributeError: 'float' object has no attribute 'exp' The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/home/negm/PycharmProjects/testa2/a2_1.py", line 47, in nn_model.fit(x_train, y_train) File "/home/negm/PycharmProjects/testa2/venv/lib/python3.6/site-packages/mlrose/neural.py", line 528, in fit restarts=0, init_state=init_weights) File "/home/negm/PycharmProjects/testa2/venv/lib/python3.6/site-packages/mlrose/algorithms.py", line 188, in random_hill_climb problem.set_state(init_state) File "/home/negm/PycharmProjects/testa2/venv/lib/python3.6/site-packages/mlrose/opt_probs.py", line 224, in set_state self.fitness = self.eval_fitness(self.state) File "/home/negm/PycharmProjects/testa2/venv/lib/python3.6/site-packages/mlrose/opt_probs.py", line 98, in eval_fitness fitness = self.maximize*self.fitness_fn.evaluate(state) File "/home/negm/PycharmProjects/testa2/venv/lib/python3.6/site-packages/mlrose/neural.py", line 290, in evaluate self.y_pred = self.output_activation(outputs) File "/home/negm/PycharmProjects/testa2/venv/lib/python3.6/site-packages/mlrose/activation.py", line 77, in sigmoid fx = 1/(1 + np.exp(-x)) TypeError: loop of ufunc does not support argument 0 of type float which has no callable exp method`

The weird thing is i tried different activation functions, but it always maps back to 'sigmoid' !!

gkhayes commented 4 years ago

I'm not quite sure what is causing this issue. I haven't come across it before, but would be interested to hear if anyone else has and if they have found a way of solving it.