我正试图在DeepLearning.ai课程作业中完成一些作业。
当我尝试在Coursera上分配任务时,一切都很好,但是,当我尝试在本地机器上执行相同的imports
时,它会给我一个错误,
ModuleNotFoundError: No module named 'lr_utils'
我试图通过安装lr_utils
来解决这个问题,但没有结果。
网上没有提到这个模块,现在我开始怀疑这是否是deeplearning.ai
的专利
或者我们可以用其他方式解决这个问题吗?
发布于 2019-04-14 08:53:58
您将能够找到分配所需的lr_utils.py
和所有其他.py
文件(以及其中的代码):
。
然后,您可以将模块的代码直接包含在代码中。
发布于 2018-06-23 10:58:35
从上面的答案下载数据集。
并使用以下代码(它比上面的代码更好,因为它在使用后关闭文件):
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
发布于 2018-04-01 05:13:43
"lr_utils“不是官方图书馆之类的。"lr_utils“的目的是获取课程所需的数据集。
- I had a problem with fetching data from provided url (but at least you can try to run it, maybe it will work)
- [link for dataset download](https://pan.baidu.com/s/1gfGhPLp)
- [link for lr\_utils.py script download](https://pan.baidu.com/s/1pLv8Mx1)
- Remember to extract dataset when you download it and you have to put dataset folder and "lr\_utils.py" in the same folder as your python script that is using it (script with this line "import lr\_utils").
https://stackoverflow.com/questions/49311929
复制相似问题