Pooya
Pooya

Reputation: 29

Import Keras on Jupyter Notebook

I am new to Ml (Cat & Dog Detection). I have trouble in using Keras library in a Jupyter Notebook.

I tried to install Tensorflow within jupyter note book by this:

 import tensorflow as tf

I don't know if this is right way to call Keras but in second cell i tried:

from keras.models import Sequential

Error:

    ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-10-9c5e0a19b646> in <module>
----> 1 from keras.models import Sequential

ModuleNotFoundError: No module named 'keras'

Absolutely Keras is not a module in Tensorflow library 😂, If cant get it with Tensorflow how should I call it?

Upvotes: 2

Views: 37367

Answers (3)

Nishant
Nishant

Reputation: 21

When you install tensorflow 2.x, keras is installed along with it. Thus you can import keras from tensorflow:

from tensorflow.keras import Sequential

Upvotes: 2

Akshita Khatri
Akshita Khatri

Reputation: 1

!pip install Keras. I tried this command only but I got an error. !pip install TensorFlow should also be downloaded to import keras. so I think we need to download them both. And my code is running perfectly

Upvotes: -1

You have to do !pip install keras within your jupyter notebook to install the keras package before you can import keras. Keras uses tensorflow backend, so when you install keras it installs tensorflow as part of the requirements.

Upvotes: 7

Related Questions