python - Keras 负载权重 : OSError: Unable to open file (Truncated file: eof = 41091072)

标签 python keras h5py

当我尝试使用 keras' model.load_weights 加载权重时 我得到 OSError: Unable to open file (Truncated file: eof = 41091072) 这是完整的错误跟踪:

model.load_weights(get_file(fname, "E:/Work/Practical\ Deep\ Learning\ Course/my\ notebooks/lesson1/vgg16.h5", cache_subdir='models'))
    141 
    142 

C:\....\Anaconda3\envs\tensorflow\lib\site-packages\keras\engine\topology.py in load_weights(self, filepath, by_name)
   2700         """
   2701         import h5py
-> 2702         f = h5py.File(filepath, mode='r')
   2703         if 'layer_names' not in f.attrs and 'model_weights' in f:
   2704             f = f['model_weights']

C:\....\Anaconda3\envs\tensorflow\lib\site-packages\h5py\_hl\files.py in __init__(self, name, mode, driver, libver, userblock_size, swmr, **kwds)
    269 
    270                 fapl = make_fapl(driver, libver, **kwds)
--> 271                 fid = make_fid(name, mode, userblock_size, fapl, swmr=swmr)
    272 
    273                 if swmr_support:

C:\....\Anaconda3\envs\tensorflow\lib\site-packages\h5py\_hl\files.py in make_fid(name, mode, userblock_size, fapl, fcpl, swmr)
     99         if swmr and swmr_support:
    100             flags |= h5f.ACC_SWMR_READ
--> 101         fid = h5f.open(name, flags, fapl=fapl)
    102     elif mode == 'r+':
    103         fid = h5f.open(name, h5f.ACC_RDWR, fapl=fapl)

h5py\_objects.pyx in h5py._objects.with_phil.wrapper (D:\Build\h5py\h5py-2.7.0\h5py\_objects.c:2853)()

h5py\_objects.pyx in h5py._objects.with_phil.wrapper (D:\Build\h5py\h5py-2.7.0\h5py\_objects.c:2811)()

h5py\h5f.pyx in h5py.h5f.open (D:\Build\h5py\h5py-2.7.0\h5py\h5f.c:2130)()

OSError: Unable to open file (Truncated file: eof = 41091072, sblock->base_addr = 0, stored_eoa = 553482496)

我该如何处理?

最佳答案

我的是 Windows 10。这解决了我的错误- 走这条路 C:\用户\你的名字\.keras\模型\vggface 并删除 h5 文件并重新运行代码。

关于python - Keras 负载权重 : OSError: Unable to open file (Truncated file: eof = 41091072),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44996988/

相关文章:

h5py - 如何使用 h5py 遍历 hdf5 文件

python - 为什么这个 Keras 模型需要超过 6GB 的内存?

python - Keras/Tensorflow : Predict Using tf. 数据.数据集 API

python - ValueError : could not broadcast input array from shape (300, 300,3) 变成形状 (300,300)

python h5py文件读取 "OSError: Unable to open file (bad superblock version number)"

python - 使用h5py读取HDF5时出错

python - 在python中设置环境变量来运行程序

python局部变量奇怪的行为

python - 计算字符串个数

python - 从 python 中的集合列表中删除大括号