最近在学吴恩达深度学习课,遇到一些问题,使用pycharm解释器,下面是L1W2的程序
import matplotlib
import numpy as np
import matplotlib.pyplot as plt
import h5py
import scipy
from PIL import Image
from scipy import ndimage
from lr_utils import load_dataset
train_set_x_orig, train_set_y, test_set_x_orig, test_set_y, classes = load_dataset()
index = 5
plt.imshow(train_set_x_orig[index])
print ("y = " + str(train_set_y[:, index]) + ", it's a '" + classes[np.squeeze(train_set_y[:, index])].decode("utf-8") + "' picture.")
plt.show()
运行之后出现下面的问题
F:\python\Scripts\python.exe F:/pythonProject/main.py
Traceback (most recent call last):
File "F:/pythonProject/main.py", line 10, in
train_set_x_orig, train_set_y, test_set_x_orig, test_set_y, classes = load_dataset()
File "F:\pythonProject\lr_utils.py", line 6, in load_dataset
train_dataset = h5py.File('datasets/train_catvnoncat.h5', "r")
File "F:\python\lib\site-packages\h5py\_hl\files.py", line 533, in __init__
fid = make_fid(name, mode, userblock_size, fapl, fcpl, swmr=swmr)
File "F:\python\lib\site-packages\h5py\_hl\files.py", line 226, in make_fid
fid = h5f.open(name, flags, fapl=fapl)
File "h5py\_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
File "h5py\_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
File "h5py\h5f.pyx", line 106, in h5py.h5f.open
FileNotFoundError: [Errno 2] Unable to open file (unable to open file: name = 'datasets/train_catvnoncat.h5', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0)
Process finished with exit code 1
想知道是什么情况,怎么解决?
有没有这个文件datasets/train_catvnoncat.h5?
不知道你这个问题是否已经解决, 如果还没有解决的话: