Keras加载权重:OSError:无法打开文件(截断文件:eof = 41091072)

问题描述 投票:2回答:2

当我尝试使用keras'model.load_weights I get 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)

我怎么处理这个?

python keras h5py
2个回答
-1
投票

我是Windows 10.这解决了我的错误 - 转到此路径C:\ Users \ you_name \ .keras \ models \ vggface并删除h5文件并重新运行代码。


-2
投票

哦!我刚刚找到了方法,删除了前列车模型'**。h5',然后重新下载。

© www.soinside.com 2019 - 2024. All rights reserved.