skip to Main Content

I need help with this Problem: Import "lab_utils_uni" could not be resolved. I installed numpy and matplotlib but lab_utils_uni didnt work. I am working with Visual Studio Code btw.

import numpy as np
import matplotlib.pyplot as plt
from lab_utils_uni import plt_intuition, plt_stationary, plt_update_onclick, soup_bowl


x_train = np.array([1.0, 2.0])           
y_train = np.array([300.0, 500.0])           

def compute_cost(x, y, w, b): 
    # number of training examples
    m = x.shape[0] 
    
    cost_sum = 0 
    for i in range(m): 
        f_wb = w * x[i] + b   
        cost = (f_wb - y[i]) ** 2  
        cost_sum = cost_sum + cost  
    total_cost = (1 / (2 * m)) * cost_sum  

    return total_cost

    plt_intuition(x_train,y_train)

3

Answers


  1. enter image description here

    It’s a "reportMissingImports" warning.

    lab_utils_uni is local drawing routines.

    You need a lab_utils_uni.py file in your workspace.

    Login or Signup to reply.
  2. Thatʻs simple, copy lab_utils_uni.py file to the same directory your code is saved to. You can download that python files from the "files" tab on Coursera online tab.

    Login or Signup to reply.
  3. This code is from Coursera – DeepLearning AI course.

    lab_utils_uni is a common util library which is used to run the code in the Online Lab in Coursera but doesn’t show up in the Lab files section.

    To look at the contents of the file try this:

    import inspect, os
    path = os.path.abspath(inspect.getfile(plt_stationary))
    print(path)
    f = open(path, 'r')
    content = f.read()
    print(content)
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search