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

Attribute error with scipy.misc.logsumexp and autograd #51

Closed
r-shruthi11 opened this issue Jul 26, 2019 · 7 comments
Closed

Attribute error with scipy.misc.logsumexp and autograd #51

r-shruthi11 opened this issue Jul 26, 2019 · 7 comments

Comments

@r-shruthi11
Copy link

Hi,

I think related to this issue (HIPS/autograd#501) here, I'm having trouble importing ssm because I get an attribute error trying to import logsumexp from scipy.misc. Would re-installing autograd from the master branch be the solution here?

Thanks!
Shruthi

@slinderman
Copy link
Collaborator

slinderman commented Jul 26, 2019 via email

@r-shruthi11
Copy link
Author

Thanks, Scott. I've tried that but I still see the same issue.

----> 1 import ssm

~/Desktop/Projects/state-space-models/ssm/ssm/ssm/init.py in
1 # Default imports for SSM
2
----> 3 from .hmm import *
4 from .lds import *

~/Desktop/Projects/state-space-models/ssm/ssm/ssm/hmm.py in
7
8 from ssm.optimizers import adam_step, rmsprop_step, sgd_step, convex_combination
----> 9 from ssm.primitives import hmm_normalizer, hmm_expected_states, hmm_filter, hmm_sample, viterbi
10 from ssm.util import ensure_args_are_lists, ensure_args_not_none,
11 ensure_slds_args_not_none, ensure_variational_args_are_lists, \

~/Desktop/Projects/state-space-models/ssm/ssm/ssm/primitives.py in
2 import autograd.numpy as np
3 import autograd.numpy.random as npr
----> 4 from autograd.scipy.misc import logsumexp
5 from autograd.scipy.linalg import cholesky_banded, solve_banded, solveh_banded
6 from autograd.extend import primitive, defvjp

ImportError: cannot import name 'logsumexp'

@slinderman
Copy link
Collaborator

My guess is that Python is still loading the pip installed version of Autograd. You can check by running

import autograd
autograd.__file__

and seeing what path it's pointing to. Make sure it's the path from Github.

That said, I just double checked Autograd and it looks like @mattjj just uploaded the latest Github master to PyPI. You should be able to get it by running

pip install autograd --upgrade

@r-shruthi11
Copy link
Author

r-shruthi11 commented Jul 26, 2019

Hi Scott,

I tried both - setting the autograd path to point to the Github directory and upgrading my install of autograd but I still see the same error when I try to import logsumexp from autograd.scipy.misc. However, importing logsumexp from autograd.scipy.special seems to work.

pip install autograd --upgrade
Requirement already up-to-date: autograd in /Users/shrumac2/miniconda3/envs/ssmodels/lib/python3.5/site-packages (1.3)
Requirement not upgraded as not directly required: numpy>=1.12 in /Users/shrumac2/miniconda3/envs/ssmodels/lib/python3.5/site-packages (from autograd) (1.16.4)
Requirement not upgraded as not directly required: future>=0.15.2 in /Users/shrumac2/miniconda3/envs/ssmodels/lib/python3.5/site-packages (from autograd) (0.17.1)

python
Python 3.5.6 |Anaconda, Inc.| (default, Aug 26 2018, 16:30:03)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

from autograd.scipy.misc import logsumexp
Traceback (most recent call last):
File "", line 1, in
ImportError: cannot import name 'logsumexp'
from autograd.scipy.special import logsumexp

logsumexp([1.0, 2.0, 3.0])
3.4076059644443806

@slinderman
Copy link
Collaborator

Sorry for the delay. Quick update: I reran the Travis integrations and they are also failing in the same way you describe. Unfortunately I haven't been able to reproduce the problem locally yet, and I'm currently tied up at a conference so it might take a few more days.

In the meantime, it would be helpful to also know more about your configuration: what version of numpy/scipy are you on? I'm sure there's a simple explanation for all this...

@r-shruthi11
Copy link
Author

Thanks for the update, Scott. Here's the info:

autograd==1.3
certifi==2019.6.16
cycler==0.10.0
Cython==0.29.13
future==0.17.1
joblib==0.13.2
kiwisolver==1.1.0
matplotlib==3.1.1
numpy==1.17.0
pyparsing==2.4.1.1
python-dateutil==2.8.0
scikit-learn==0.21.2
scipy==1.3.0
six==1.12.0
tqdm==4.32.2

@slinderman
Copy link
Collaborator

Thanks for your patience. The fix was simple in the end: I had to change the imports to from autograd.scipy.special import logsumexp to work with the latest versions of scipy and autograd. Fix is here 57950a8.

Note: I also made these changes in the master branch of pybasicbayes and pyhsmm to fix the nosetests.

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