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

ValueError: array must not contain infs or NaNs #119

Open
dujinyu opened this issue Nov 19, 2019 · 1 comment
Open

ValueError: array must not contain infs or NaNs #119

dujinyu opened this issue Nov 19, 2019 · 1 comment

Comments

@dujinyu
Copy link

dujinyu commented Nov 19, 2019

when i run python python/gps/gps_main.py box2d_pointmass_pi2_example, the following error occurs.

('__file__:', 'python/gps/gps_main.py')
('add path:', 'python')
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
Initializing pygame framework...
DEBUG:tm._add: /joy, sensor_msgs/Joy, sub
DEBUG:tm._add: /camera/rgb/image_color, sensor_msgs/Image, sub
DEBUG:Unrecognized keyboard input: escape
DEBUG:Unrecognized keyboard input: escape
/home/vector/PythonVirtualEnvs/gps/local/lib/python2.7/site-packages/scipy/optimize/_minimize.py:298: RuntimeWarning: Method BFGS cannot handle constraints nor bounds.
  RuntimeWarning)
python/gps/algorithm/traj_opt/traj_opt_pi2.py:223: RuntimeWarning: overflow encountered in exp
  np.sum(np.exp(exponent / eta))))
/home/vector/PythonVirtualEnvs/gps/local/lib/python2.7/site-packages/scipy/optimize/optimize.py:597: RuntimeWarning: invalid value encountered in subtract
  grad[k] = (f(*((xk+d,)+args)) - f0) / d[k]
/home/vector/PythonVirtualEnvs/gps/local/lib/python2.7/site-packages/scipy/optimize/linesearch.py:414: RuntimeWarning: invalid value encountered in double_scalars
  radical = B*B-3*A*C
[[ nan  nan]
 [ nan  nan]]
Traceback (most recent call last):
  File "python/gps/gps_main.py", line 108, in run
    self._take_iteration(itr, traj_sample_lists)  # 迭代
  File "python/gps/gps_main.py", line 253, in _take_iteration
    self.algorithm.iteration(sample_lists)
  File "python/gps/algorithm/algorithm_traj_opt_pi2.py", line 33, in iteration
    self._update_trajectories()
  File "python/gps/algorithm/algorithm.py", line 128, in _update_trajectories
    self.traj_opt.update(cond, self)
  File "python/gps/algorithm/traj_opt/traj_opt_pi2.py", line 95, in update
    fixed_eta, use_fixed_eta
  File "python/gps/algorithm/traj_opt/traj_opt_pi2.py", line 177, in update_pi2
    mult = np.trace(np.dot(sp.linalg.inv(cov_old[t]),
  File "/home/vector/PythonVirtualEnvs/gps/local/lib/python2.7/site-packages/scipy/linalg/basic.py", line 308, in inv
    a1 = np.asarray_chkfinite(a)
  File "/home/vector/PythonVirtualEnvs/gps/local/lib/python2.7/site-packages/numpy/lib/function_base.py", line 1216, in asarray_chkfinite
    "array must not contain infs or NaNs")
ValueError: array must not contain infs or NaNs

According to the err info, when we run sp.linalg.inv() in traj_opt_pi2.py, the matrix cov_old[t] contains infs or NaNs. I don't find a suitable solution after google. Did you encounter this err? If you did, how to address this err? Thanks.

@ljiang43
Copy link

ljiang43 commented Apr 9, 2021

Hi, I got this problem too when I used scipy.optimize.minimize! Did you solve it at the end? Thanks for your sharing : )

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