How to load dataset at 'Google Colab' page to run the assignment successfully?

I am trying to run my successfully submitted assignment of Course 1 Week 2 on my google colab page. I am not able to load dataset. Please help.

Hey, Khushboo.

Welcome to the community.

First of all let us know for which assignment are you talking about as i can’t locate it from the given screenshot.

For Google Colab, you need to mount the files on your google drive. Once it is connected then you need to run them by running the cells through shift+enter key as per the given instructions. If you miss any step, it will definitely cause an error.

The Google Colab works on the same pattern as python. But you need to be careful with GPU runtime. A slow-paced PC will delay running the cell. You always need to check whether the colab page is connected with the asked runtime. TPU is only to be chosen when asked.

Also, you should note one important thing here that once the runtime is disconnected then you have to connect it again and run all the cells from the beginning otherwise it will never going to work and you will never achieve the desired output.

As Rashmi says, the point is that just copying the notebook itself is not enough. There is a whole tree of supporting files that you need along with the notebook, if you want to run the notebook in some different environment. There is a topic on the DLS FAQ Thread about how to download all the files. But note that the course has given you a working environment on the Coursera website, so it’s not our job to be your IT support staff if you choose to run things in a different environment. You’ll need to develop your own skills for solving that type of problem, otherwise it just never ends, right? :nerd_face:

Dear Khushboo,

To answer your query that you had requested me a day back, let me start with the understanding that Google Colab schedules the same features as python, but to set up any such notebook on your laptop/pc, you need to execute a lot of conda files that facilitate at the back to make your work easier. These files are nothing, but the software programmings that are run at the back and collate with the environment.

I can see that you have managed to upload the Logistic Regression notebook file on Google Colab and that’s commendable. But I cannot see the actual lab files needed to run the notebook? Here’s a screenshot:

This means that you need to download the lab files from left corner and must upload it on the google drive and then you need to extract all the files from that folder to erase out any such errors that you may receive after running the first cell as ‘missing lr utils’.

You might also be receiving this error:

So, what you need to do is—> open examples and find out what files are you missing again to run the colab.

You will find that the notebook will name you certain links and you have to get it downloaded.

First get all these requisites and then try working on it.

Note: you need to connect colab with the runtime (GPU)

Hello mam ,
I followed the steps as suggested by you. Installed all required packages as shown in pic below.

Same “ModuleNotFoundError” is appearing:

Hello Khushboo,

This means that colab notebook is not able to extract and recognise “” file properly.

Did you try opening this file by visiting the “” seen on the left-side of the notebook?

Each of the files need to be extracted individually.

You can also take help from this link that describes the possibilities of its failure.

Previously, I did use Colab while learning Tensorflow and other courses where colab was already built-in for assignments, but I never tried running DLS assignments such as Logistic Regression and other jupyter files on colab on my own.

This is the first time when I am trying to do it, just to help you with maximum understanding and possibilities :slight_smile:

1 Like

I think this looks like a “current working directory” problem. You can see from the file tree in the left panel that the file is present on your Google Drive. So now the question is why the notebook can’t find it. Try adding a new cell in your notebook before the “import” cell and enter the following command:


Note that the exclamation point there is necessary: it tells Jupyter that the code there is a “linux shell command” instead of python code. I hope you know enough about linux to know what “pwd” tells you. Or you can just add that line as the first line of the “import” cell. What do you see when you run that cell with the pwd command? The DLS assignment notebooks are written to assume that the directory where you are running the notebook is the same one containing all the required files. So I’ll bet that you started the notebook in a different directory or else there is just something different about how Colab handles your current working directory and that is what you need to figure out.

1 Like

Thanks a lot @Rashmi and @paulinpaloalto
I am able to remove “ModuleNotFoundError” error on my colab by changing the path of current directory as shown in pic below:

Can you please solve my another query? Why is there brown color lines still under lr_utils and public_tests as can be seen in above pic…
Is it some kind of error??

A Big Thanks to @Rashmi and @paulinpaloalto for giving your time and energy.
Now I am able to pass all tests till final model as shown in pic below.

But its giving “NameError” for training the model. What am i missing now?
Please help!

Hello Khushboo,

Glad to see that you have managed to run things and solved it. That’s brilliant.

However, I also can find a couple of queries that were still bringing you down?
Have they been resolved?

1 Like

It’s great to hear that you figured out the “current working directory” issue. For the brown underlines, my guess is that just means that those are local files as opposed to real python “packages”. Those “imports” seem to have worked, otherwise you’d be getting errors from missing functions.

For the train_set_x question, that’s a variable that is created by one of the earlier cells in the notebook, right? So are you sure you ran that cell? Did it succeed or throw an error? It should be a simple matter to search the notebook using ^F for train_set_x. What happened? This is how debugging works, right? You start from the evidence: what does the error tell you. Ok, then what? One step at a time …

1 Like

@paulinpaloalto @Rashmi

The “imports” are working successfully now.

“train_set_x” also run successfully. It might be I missed to run the cell where this variable is created.

Now I am able to run full assignment till “classify/Test you own image” successfully on google colab.

Thanks a lot for your clear instructions towards the solution and step-by-step guidance.
Super thankful to both of you…!! :slight_smile: