无法加载在谷歌Colaboratory创建的模型

问题描述 投票:1回答:3

我曾在谷歌Colab使用Keras培养了CNN,但是,在下载模式之后,我无法加载hdf5文件在我的本地系统(Windows)。

我以前做过这个,和从未有过任何问题。这是我得到的错误。

Traceback (most recent call last):
  File "D:/Work/binary-face-recognition/predict-test.py", line 27, in <module>
    model = load_model('model.hdf5')
  File "C:\Users\PARTHA.N\AppData\Local\Continuum\anaconda3\envs\face\lib\site-packages\keras\engine\saving.py", line 417, in load_model
    f = h5dict(filepath, 'r')
  File "C:\Users\PARTHA.N\AppData\Local\Continuum\anaconda3\envs\face\lib\site-packages\keras\utils\io_utils.py", line 186, in __init__
    self.data = h5py.File(path, mode=mode)
  File "C:\Users\PARTHA.N\AppData\Local\Continuum\anaconda3\envs\face\lib\site-packages\h5py\_hl\files.py", line 312, in __init__
    fid = make_fid(name, mode, userblock_size, fapl, swmr=swmr)
  File "C:\Users\PARTHA.N\AppData\Local\Continuum\anaconda3\envs\face\lib\site-packages\h5py\_hl\files.py", line 142, 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 78, in h5py.h5f.open
OSError: Unable to open file (truncated file: eof = 38486016, sblock->base_addr = 0, stored_eof = 72708080)

对于加载模型,我正在做一个基地load_model通话

from keras.models import load_model
model = load_model('model.hdf5')

要保存和下载谷歌从该Colab模型我使用下面的代码片断。

# save model
model.save('model.hdf5')

# download model
from google.colab import files
files.download('model.hdf5')

我得到了谷歌COLB以下错误在该行files.download()文件下载后。

----------------------------------------
Exception happened during processing of request from ('::ffff:172.28.0.1', 47132, 0, 0)
Traceback (most recent call last):
  File "/usr/lib/python3.6/socketserver.py", line 317, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/lib/python3.6/socketserver.py", line 348, in process_request
    self.finish_request(request, client_address)
  File "/usr/lib/python3.6/socketserver.py", line 361, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python3.6/socketserver.py", line 721, in __init__
    self.handle()
  File "/usr/lib/python3.6/http/server.py", line 418, in handle
    self.handle_one_request()
  File "/usr/lib/python3.6/http/server.py", line 406, in handle_one_request
    method()
  File "/usr/lib/python3.6/http/server.py", line 639, in do_GET
    self.copyfile(f, self.wfile)
  File "/usr/lib/python3.6/http/server.py", line 800, in copyfile
    shutil.copyfileobj(source, outputfile)
  File "/usr/lib/python3.6/shutil.py", line 82, in copyfileobj
    fdst.write(buf)
  File "/usr/lib/python3.6/socketserver.py", line 800, in write
    self._sock.sendall(b)
ConnectionResetError: [Errno 104] Connection reset by peer
----------------------------------------
python keras google-colaboratory
3个回答
1
投票

我也面临着同样的问题,我做了什么不同的是下载从文件管理器中的文件,而不是和相同的工作就好了。

点击屏幕就在colab标志下方的左上角的小箭头,看起来像

this

然后,你将需要点击的文件和导航到所需的文件,右键点击并下载所需的文件。这对我更好地工作,也没有连接错误,这是在files.download方法的情况下

files


0
投票

看起来有一些问题与互联网连接。我切换到另一个无线网络,它工作得很好。

现在的问题听起来很愚蠢,但保持它,并在希望它可以帮助别人谁在同样的问题来回答这个问题。


0
投票

description here即将

“由对等连接重置”是TCP / IP等效砰的一声电话背面上的钩。这不仅仅是没有回答,留下一个悬挂更有礼貌。但它不是FIN-ACK有望真正礼貌的TCP / IP converseur的

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