Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install issues with 'lr_utils' in python

I am trying to complete some homework in a DeepLearning.ai course assignment.

When I try the assignment in Coursera platform everything works fine, however, when I try to do the same imports on my local machine it gives me an error,

ModuleNotFoundError: No module named 'lr_utils'

I have tried resolving the issue by installing lr_utils but to no avail.

There is no mention of this module online, and now I started to wonder if that's a proprietary to deeplearning.ai?

Or can we can resolve this issue in any other way?

like image 595
JAugust Avatar asked Mar 16 '18 01:03

JAugust


3 Answers

As per the answer above, lr_utils is a part of the deep learning course and is a utility to download the data sets. It should readily work with the paid version of the course but in case you 'lost' access to it, I noticed this github project has the lr_utils.py as well as some data sets

https://github.com/andersy005/deep-learning-specialization-coursera/tree/master/01-Neural-Networks-and-Deep-Learning/week2/Programming-Assignments

Note: The chinese website links did not work when I looked at them. Maybe the server storing the files expired. I did see that this github project had some datasets though as well as the lr_utils file.

EDIT: The link no longer seems to work. Maybe this one will do?

https://github.com/knazeri/coursera/blob/master/deep-learning/1-neural-networks-and-deep-learning/2-logistic-regression-as-a-neural-network/lr_utils.py

like image 56
ThinkBonobo Avatar answered Nov 09 '22 23:11

ThinkBonobo


You will be able to find the lr_utils.py and all the other .py files (and thus the code inside them) required by the assignments:

  1. Go to the first assignment (ie. Python Basics with numpy) - which you can always access whether you are a paid user or not

  2. And then click on 'Open' button in the Menu bar above. (see the image below)

    .

Then you can include the code of the modules directly in your code.

like image 11
Jishnu Dey Avatar answered Nov 10 '22 00:11

Jishnu Dey


Download the datasets from the answer above.

And use this code (It's better than the above since it closes the files after usage):

def load_dataset():
    with h5py.File('datasets/train_catvnoncat.h5', "r") as train_dataset:
        train_set_x_orig = np.array(train_dataset["train_set_x"][:])
        train_set_y_orig = np.array(train_dataset["train_set_y"][:])

    with h5py.File('datasets/test_catvnoncat.h5', "r") as test_dataset:
        test_set_x_orig = np.array(test_dataset["test_set_x"][:])
        test_set_y_orig = np.array(test_dataset["test_set_y"][:])
        classes = np.array(test_dataset["list_classes"][:])

    train_set_y_orig = train_set_y_orig.reshape((1, train_set_y_orig.shape[0]))
    test_set_y_orig = test_set_y_orig.reshape((1, test_set_y_orig.shape[0]))

    return train_set_x_orig, train_set_y_orig, test_set_x_orig, test_set_y_orig, classes
like image 10
StationaryTraveller Avatar answered Nov 09 '22 23:11

StationaryTraveller