I am facing error in the week 1 assignment

I am facing this error ""There was a problem compiling the code from your notebook. Details:
name ‘keras’ is not defined "
while I click on the library then unable to edit

Hello Usman Afzal,
Thanks a lot for sharing your issue here. I will do my best to answer and resolve your issue. Please feel free to share screenshots if the issue persists.

“name ‘keras’ is not defined” indicates that the Keras module is not properly imported. If possible, open up a new cell on your notebook and type “!pip install keras” or type “pip install keras” on your terminal.

Once Keras is intalled, it can be imported using the following line:
import keras

Please check for spelling errors on your notebook. keras might have been misspelled on the import statement.

If the error message persists, it is necessary to check the Jupyter notebook kernel and make sure that it is using the correct Python environment. The kernel can be changed by selecting “Kernel” from the Jupyter notebook menu and then selecting the desired kernel.

Please feel free to share the issue still exists by a screenshot of your notebook. Please make sure that you are running all of the cells in your notebook.

I am here to help, feel free to reply on this thread regarding your issue.
Can Koz

Every time you open a notebook, you have to run all of the cells starting from the top. This is because that’s where the packages are imported and the data sets are created.

The baseline code from the notebook only imports tensorflow with the following:

import tensorflow as tf

However, keras is part of the tensorflow, thus you can still import it without using pip, but with a small change to the syntax seem on the video lesson (prepending with tf.*):

  • keras.Sequential to tf.keras.Sequential
  • keras.layers to tf.keras.layers

(post deleted by author)

All you need to do is below import section create a new cell and run ‘from tensorflow import keras’

that’s not the right solution as you are not suppose to edit or add any new cell in this assignment or add an import statement in a grade cell.

it is more related to how the layer has been recalled in the tensorflow. also kindly do not respond on such old posts as your response can confuse some other learners.