【问题标题】:No module named 'testCases_v4' [closed]没有名为“testCases_v4”的模块[关闭]
【发布时间】:2018-04-11 08:53:03
【问题描述】:

我直接复制了coursera的代码,结果是这样enter image description here

我该怎么办?

import numpy as np
import h5py
import matplotlib.pyplot as plt
from testCases_v4 import *
from dnn_utils_v2 import sigmoid, sigmoid_backward, relu, relu_backward

%matplotlib inline
plt.rcParams['figure.figsize'] = (5.0, 4.0) # set default size of plots
plt.rcParams['image.interpolation'] = 'nearest'
plt.rcParams['image.cmap'] = 'gray'

%load_ext autoreload
%autoreload 2

np.random.seed(1)

这就是我得到的

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-4-5084fe490343> in <module>()
  2 import h5py
  3 import matplotlib.pyplot as plt
----> 4 from testCases_v4 import *
  5 from dnn_utils_v2 import sigmoid, sigmoid_backward, relu, relu_backward
  6 

ModuleNotFoundError: No module named 'testCases_v4'

【问题讨论】:

  • 请分享您的代码并解释您面临的问题,以便有效地帮助您。
  • 感谢您的建议

标签: python machine-learning deep-learning


【解决方案1】:

那是因为您正在导入系统找不到的文件 (testCases_v4.py),而您的系统中可能没有该文件。 您可以尝试从此链接 (testCases_v4) 下载文件 到您的系统中,python 可以找到它的地方。

对于 ddn_utils_v2.py,您可能会遇到同样的错误,您可以从 ddn_utils_v2 下载它

【讨论】:

  • 嗯无法访问这些链接,但这是一个有趣的资源,可以访问自己的项目。
【解决方案2】:

我已经意识到我要导入的库不在我需要的本地主机中 从 coursera 提供的 jupyter notebook 导入或者直接从网上下载一个

【讨论】:

    猜你喜欢
    • 2018-02-23
    • 1970-01-01
    • 2021-08-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多