Coding environment (Colab tips)

I don’t exactly know whether it is better and faster than Jupyter. But if you want to give it a try, here is the step-by-step guide.

Before starting, it is recommended that first, passed all the assignments and then try this approach.

So, here are the steps:

Step 1: Download all the assignment files. First click on the Lab Files and then Download all files as shown in below Figure.

Step 2: Unzip that folder and you’ll notice multiple unnecessary levels in the directory hierarchy such as Files/Files/home/jovyan/work/release/(Assignment_related_folder_name) . In the below image, the Assignment_related_folder_name is W2A1 , which differs for each assignment, but usually comes after the release folder. Only upload this folder to Google Drive (in this case, it is W2A1) as it contains all the necessary assignment files and folders.

Step 2

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.

Step 4: Now inside the “W2A1” folder, you need to open a file with .ipynb extension, as shown in the below Figure.

Step 5: Right-click on the .ipynb extension file and open it with Google Colaboratory, as shown in below Figure. It will open in a new window.

Step 6: Click on the file icon on the left side and then click on the Google Drive icon, as shown in below Figure. This will mount (connect) Drive with Colab.

Step 7: After clicking on a Drive icon, it will generate a new cell in your notebook, as shown in below Figure. Make sure that new cell should be before the import cell. Run that cell. It will open a popup and ask to allow Google Drive to access. Allow it.

Step 8: After step 7, you need to add a new cell (before the import cell) and type the below code in it but make sure to change the “DLS/DLS 2/W2A1” to yours path.

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

If the above code output is True, you are ready to go.

Now run the import cell.

If you are getting ModuleNotFoundError: No module named ‘dlai_tools’, you need to run the below code (before the import cell).

!pip install dlai-tools

If you are getting ModuleNotFoundError: No module named ‘ipympl’, you need to run the below code (before the import cell).

!pip install ipympl

And, if you are getting ValueError: bad marshal data (unknown type code). This typically happens when Coursera use to generate files in one Python version (e.g., 3.6) or TensorFlow version and then you try to load that model in another Python version (e.g., 3.9) or TensorFlow version.

In this case, you can downgrade the Python or TF version in Colab but there will be many other packages that will not be compatible with downgraded version of Python or TF and will create several conflicts in the system. So, I recommend to read this post in this type of situation.

And, if you want to create a local environment in your local computer, read this post.