Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Input contains NaN, infinity or a value too large for dtype('float64') #26

Closed
juanantoniobellido opened this issue Jul 14, 2020 · 1 comment

Comments

@juanantoniobellido
Copy link

Hello.

I have the following error when running the evolution: "ValueError: Input contains NaN, infinity or a value too large for dtype('float64')." (I upload the whole text in "error.txt")

The input data do not have any NaN value, and the format is 'float64'. The problem may be in 'y_pred', because when I delete the functions pow, sqrt and log, everything works fine (using any of them, the problem arises):

pset = gep.PrimitiveSet('Main', input_names=inputs[:-1])
pset.add_function(operator.add, 2)
pset.add_function(operator.sub, 2)
pset.add_function(operator.mul, 2)
pset.add_function(protected_div, 2)
pset.add_function(operator.pow, 2)
pset.add_function(np.sqrt, 1)
pset.add_function(np.log, 1)
pset.add_rnc_terminal()

I also upload the implementation file in the .zip

Thank you very much in advance

error_and_py.zip

@ShuhuaGao
Copy link
Owner

This is not a rare case in genetic programming. Even if all your inputs are regular numbers, a randomly generated GP expression may still produce a very huge number. For example, supposing your input is a=100, b=0.01, pow(a / b, a) is an extremely large number.

However, I think you should pay special attention to pset.add_function(np.sqrt, 1) and pset.add_function(np.log, 1) , and you better provide a protected version for them. E.g., both np.sqrt(-1) and np.log(-1) leads to nan.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants