Importing libraries

What do I need to install using “pip install” to import and use, from cnn_utils import *, from test_utils import summary, comparator and import tensorflow.keras.layers as tfl in week 1 assignment 2.

1

Hey @Chinmay_Sahoo,
The cnn_utils and test_utils are .py files which you can download from the coursera lab. For instructions to download these files, you can refer to this post. Apart from that, you only need to install Tensorflow, as per your screenshot. I hope this helps.

Regards,
Elemento

I have installed tensorflow but still its saying Import “tensorflow.keras.layers” could not be resolvedPylancereportMissingImports

View Problem

Hey @Chinmay_Sahoo,
Apologies for my previous response. I didn’t see that you have already installed tensorflow. Mind sharing the version of your tensorflow installation?

Also, can you please try using
from tensorflow.keras.layers import Dense
instead of
import tensorflow.keras.layers as tfl & tfl.Dense

Regards,
Elemento

My tensorflow version is “2.9.0-dev20220319”. Using “from tensorflow.keras.layers import Dense” isn’t working it’s showing the same error.

This is strange, since this worked out without any issue on the Coursera Lab and even on my personal environment. Can you please try using tf.keras.layers.Dense and so on, in your local environment?

Also, can you ensure that import tensorflow.keras.layers as tfl works in the Coursera Lab, and the version of Tensorflow in your Coursera Lab?

Regards,
Elemento

In Coursera Lab, the version of Tensorflow is 2.3.0 how can I update Tensorflow in my local environment?

Hey @Chinmay_Sahoo,
The easiest way is to uninstall your tensorflow, and download Tensorflow 2.8x. However, if you want to remain on Tensorflow 2.9x, you can create a virtual environment in your local system, and install Tensorflow 2.8x in that, to complete your assignment in your local system. I hope this helps.

Regards,
Elemento

hello

I am having the same issue, I installed and yet it failed to import. can you please help!!!

Please check this guide on how to run assignment files on Colab.

Hello Saif,

I am sorry I am non-IT person, can you show me the way to find my path to the file(yours is this)

import os
os.chdir(‘/content/drive/My Drive/DLS/DLS 2/W2A1’)
os.path.exists(‘/content/drive/My Drive/DLS/DLS 2/W2A1’)

It depends on how you save your files in Google Drive. Check the step 3 again:

Step 3: I uploaded that “W2A1” folder to my drive like that My Drive>DLS>DLS 2 as shown in below image. So, the path to assignments files is My Drive/DLS/DLS 2/W2A1. You have to remember yours.

Saif I completed this step

next step is to install
so I need to type this

!pip install TensorFlow.keras??

when I did I get this??

ERROR: Could not find a version that satisfies the requirement tensorflow.keras (from versions: none)
ERROR: No matching distribution found for tensorflow.keras

seems like I need to download with the version mentioned but I am not sure which version I need to install, can you guide me through

You don’t need to do !pip install tensorflow. Its already in Colab.
Please share your full error. Which assignment you are doing?

yes it was there and it was working also but since today morning it was not working. Now I downloaded the pip install TensorFlow, it is working. I am doing tf-at course 4 week 4 assignment

I am stil having the issue. I am not understanding. tensor and keras is installed and yet shows missing. Can I share my this assignment notebook?

I just ran the TF1 C4 W4 assignment on my Colab and it works smoothly. Please share your error.

hey I am not tf1 course, I am doing TensorFlow advanced specialisation course 4 Generative Deep Learning with TensorFlow week 4 assignment name Generated Hands.

I am sharing the notebook please have a look

I didn’t do this specialization but you can send me your notebook in a direct message. Click my name and message.

the issue is not related to the code in particular to the course but related to library import, so I guess you must be having some idea. I have sent the notebook. please have a look, thank you for your time and response