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

Optimization demo looks broken #6

Closed
chenliu0831 opened this issue Oct 15, 2014 · 6 comments
Closed

Optimization demo looks broken #6

chenliu0831 opened this issue Oct 15, 2014 · 6 comments

Comments

@chenliu0831
Copy link

Running ch.demo('optimization') and halted.

1.42e+02 | e1: 2.25e+01 | e2: 5.06e+01 | e3: 6.89e+01 | 
/Library/Python/2.7/site-packages/scipy/sparse/linalg/dsolve/linsolve.py:145: MatrixRankWarning: Matrix is exactly singular
  warn("Matrix is exactly singular", MatrixRankWarning)

Ctrl-c gives

/Users/chenyangliu/Desktop/BL-dev/chumpy/ch.pyc in __setattr__(self, name, value, itr)
    342             if name == 'x':
    343                 self._dirty_vars.add(name)
--> 344                 self.clear_cache(itr)
    345             #else:
    346             #    import warnings

/Users/chenyangliu/Desktop/BL-dev/chumpy/ch.pyc in clear_cache(self, itr)
    404 
    405                 for parent, parent_dict in next._parents.items():
--> 406                     object.__setattr__(parent, '_dirty_vars', parent._dirty_vars.union(parent_dict['varnames']))
    407                     parent._invalidate_cacheprop_names(parent_dict['varnames'])
    408                     todo.append(parent)
@mattloper
Copy link
Owner

What version of chumpy are you running? Is it from pipy or from latest master on github? For me, ch.demo('optimisation') is working.

@chenliu0831
Copy link
Author

I'm using the latest master.

@mattloper
Copy link
Owner

From my testing, it seems that Mavericks exhibits no problem, Ubuntu 12.04 gives a warning but still works, and Ubuntu 14.04 hangs. I don't know what is causing the problem, or why behavior is different across platforms.

@chenliu0831
Copy link
Author

Oh. It actually hangs on my mac. Probably the default numpy and scipy version is different across platform. I am using scipy==0.14.0, numpy==1.8.2 on my mac.

@chenliu0831
Copy link
Author

@mattloper Sorry I accidentally deleted the previous comment. In scipy 0.14.0, scipy.sparse.linalg.spsolve is filling nan if singular matrix is detected. See diff line 139 in scipy/scipy@2344e41

@mattloper
Copy link
Owner

Finally fixed this, by falling back to scipy.sparse.linalg.lsqr when warnings are fired (typically with a singular matrix). The problem is that when any single column of the Jacobian is all-zeros, the predicted hessian is non-invertable. Sometimes such zero-columns indicates user-error (optimizing over vars that don't affect output), other times not.

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