Keras: Cannot Import Name np_utils

Viewed 22283

I'm using Python 2.7 and a Jupyter notebook to do some basic machine learning. I'm following along with this tutorial:

http://machinelearningmastery.com/regression-tutorial-keras-deep-learning-library-python/

I'm simply trying to import different things from Keras so I can run the tutorial. Specifically, I do this:

from keras.models import Sequential
from keras.layers import Dense
from keras.wrappers.scikit_learn import KerasRegressor
from sklearn.model_selection import cross_val_score
from sklearn.model_selection import KFold
from sklearn.preprocessing import StandardScaler
from sklearn.pipeline import Pipeline

and it gets stuck at the first import, giving me a traceback of this:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-28-aae66d0fdaee> in <module>()
----> 1 from keras.models import Sequential
      2 from keras.layers import Dense
      3 from keras.wrappers.scikit_learn import KerasRegressor
      4 from sklearn.model_selection import cross_val_score
      5 from sklearn.model_selection import KFold

/Users/newscred/anaconda/lib/python2.7/site-packages/keras/__init__.py in <module>()
      1 from __future__ import absolute_import
      2 
----> 3 from . import utils
      4 from . import activations
      5 from . import applications

/Users/newscred/anaconda/lib/python2.7/site-packages/keras/utils/__init__.py in <module>()
      1 from __future__ import absolute_import
----> 2 from . import np_utils
      3 from . import generic_utils
      4 from . import data_utils
      5 from . import io_utils

ImportError: cannot import name np_utils

I've Googled around but can't seem to find out why I'm running into this problem / how to fix. Any ideas?

Thanks!

4 Answers
Related