np_utils
is a separate package (and a keras dependency - which doesn't get install with it). Can be installed using pip:
pip install np_utils
using - Keras==2.0.6
Suggestion:
For some odd (and still unknown) reasons, even after installing the import
from keras.utils.np_utils import to_categorical
didn't work - I had to restart the notebook (first restart even didn't work), and once it worked, I got stuck again for same import call (gave exception for no module named tensorflow
) - as in utils there's another import from . import conv_utils
, which required the tensorflow.
I did try installing tensorflow using pip install tensorflow gave:
Could not find a version that satisfies the requirement tensorflow
(from versions: ) No matching distribution found for tensorflow
even this gist didn't work for me.
Finally, I installed Anaconda - which have all the scientific packages (numpy, scipy, scikit-learn,..) pre-installed. Installed keras:
conda install keras
Best thing was, it even installed tensorflow as its dependency.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…