C1 W1 Optional Lab 4: Error when running the lab locally

I know that there is a thread for that already but even following the instructions I was not able to fix the problem.

I am still seeing the “OverflowError: Python int too large to convert to C long” error even after making the changes into lab_utils_uni.py file.

I am running the jupyter notebooks locally using Visual Studio Code.

Can someone help please?

That’s the problem. The labs are intended to be run on Coursera.

Most likely you have some package versions that are newer (and not compatible) with the notebook’s code.

Ok, but I think every student is willing to re-use the code in later projects. Can you guide us on how to still make use of those notebooks after the course ?

Tks

You need to figure what module is causing an integer overflow.

I believe there is information in the MLS course FAQ about how to run the assignment locally.

Hi all, I solved this problem by

  • mentor edit - code removed

I hope it works for you as well :slight_smile:

I think that is a wrong solution. Neither cost nor z should be integers.

Did you execute this project on your computer before removing my response? When you run this notebook, W1 Lab04, on a Windows machine, you get this error “OverflowError: Python int too large to convert to C long”, because these values 32 bits integers on Windows machines, and what I did was make them 64 bits integers and it works?

But those variables are not integers in any way. They’re both floats.

I just checked to make sure

  1. cost = np.zeros_like(w_array) to cost = np.zeros_like(w_array, dtype=np.float64)
  2. z=np.zeros_like(tmp_b) to z=np.zeros_like(tmp_b, dtype=np.float64)
    works.
1 Like

Hi, I have done the same thing but the same error is still there. Is there anything else I missed? Thanks

Hi Lucas, I tried the solution given by @SametGL but needed to restart the kernel and run all again. After that it worked great on my PC (Windows 11 using VS Code).

In my case, I had to replace the cost and z variables as SametGL suggested:

In the lab_utils_uni.py file, specifically in the plt_divergence function: I have changed cost and z variables to their respective changes (dtype=np.float64)

After that, of course, do not forget to save this file. Then, in the lab, use the “Restart” button in VS Code to restart the kernel. Finally, use the button “Run All”.

Let me know how it goes for you!

1 Like