簡體   English   中英

kaggle 無法下載 resnet50 預訓練模型

[英]kaggle could not download resnet50 pretrained model

我正在嘗試在 Kaggle 內核上使用 resnet50 預訓練模型。

但是,當我運行以下代碼時,發生錯誤並且無法下載預訓練模型。 我怎樣才能讓它工作?

from keras.applications.resnet50 import ResNet50
from keras.preprocessing import image
from keras.applications.resnet50 import preprocess_input, decode_predictions
import numpy as np

model = ResNet50(weights='imagenet', include_top=False)

錯誤:

-> 1318 encode_chunked=req.has_header('傳輸編碼')) 1319
除了 OSError 作為 err: # timeout error ...

例外: https : //github.com/fchollet/deep-learning-models/releases/download/v0.2/resnet50_weights_tf_dim_ordering_tf_kernels_notop.h5上的 URL 獲取失敗:無 -- [Errno -2] 名稱或服務未知

所有日志:

使用 TensorFlow 后端。 /opt/conda/lib/python3.6/importlib/_bootstrap.py:219: RuntimeWarning: 模塊 'tensorflow.python.framework.fast_tensor_util' 的編譯時版本 3.5 與運行時版本 3.6 不匹配 return f(*args, **kwds )

https://github.com/fchollet/deep-learning-models/releases/download/v0.2/resnet50_weights_tf_dim_ordering_tf_kernels_notop.h5下載數據

-------------------------------------------------- ------------------------- gaierror Traceback (最近一次調用最后一次) /opt/conda/lib/python3.6/urllib/request.py in do_open(自我,http_class,req,**http_conn_args)1317
h.request(req.get_method(), req.selector, req.data, headers, -> 1318 encode_chunked=req.has_header('Transfer-encoding')) 1319
除了 OSError 作為 err: # timeout error

/opt/conda/lib/python3.6/http/client.py in request(self, method, url, body, headers, encode_chunked) 1238 """向服務器發送一個完整的請求。""" -> 1239 self ._send_request(method, url, body, headers, encode_chunked) 1240

/opt/conda/lib/python3.6/http/client.py in _send_request(self, method, url, body, headers, encode_chunked) 1284 body = _encode(body, 'body') -> 1285 self.endheaders(body第 1286 章

/opt/conda/lib/python3.6/http/client.py in endheaders(self, message_body, encode_chunked) 1233 raise CannotSendHeader() -> 1234 self._send_output(message_body, encode_chunked=encode_chunked) 1235

/opt/conda/lib/python3.6/http/client.py in _send_output(self, message_body, encode_chunked) 1025 del self._buffer[:] -> 1026 self.send(msg) 1027

/opt/conda/lib/python3.6/http/client.py in send(self, data) 963 if self.auto_open: --> 964 self.connect() 965 else:

/opt/conda/lib/python3.6/http/client.py in connect(self) 1391 -> 1392 super().connect() 1393

/opt/conda/lib/python3.6/http/client.py in connect(self) 935 self.sock = self._create_connection( --> 936 (self.host,self.port), self.timeout, self.源地址)937 self.sock.setsockopt(socket.IPPROTO_TCP,socket.TCP_NODELAY,1)

/opt/conda/lib/python3.6/socket.py in create_connection(address, timeout, source_address) 703 err = None --> 704 for res in getaddrinfo(host, port, 0, SOCK_STREAM): 705 af, socktype,原型,規范名稱,sa = res

/opt/conda/lib/python3.6/socket.py in getaddrinfo(host, port, family, type, proto, flags) 744 addrlist = [] --> 745 for res in _socket.getaddrinfo(host, port, family , 類型, 原型, 標志): 746 af, socktype, proto, canonname, sa = res

gaierror: [Errno -2] 名稱或服務未知

在處理上述異常的過程中,又發生了一個異常:

URLError Traceback(最近一次調用)/opt/conda/lib/python3.6/site-packages/Keras-2.0.6-py3.6.egg/keras/utils/data_utils.py in get_file(fname, origin, untar , md5_hash, file_hash, cache_subdir, hash_algorithm, extract, archive_format, cache_dir) 219 try: --> 220 urlretrieve(origin, fpath, dl_progress) 221 除了 URLError 為 e:

/opt/conda/lib/python3.6/urllib/request.py in urlretrieve(url, filename, reporthook, data) 247 --> 248 with contextlib.closure(urlopen(url, data)) as fp: 249 headers = fp.info()

/opt/conda/lib/python3.6/urllib/request.py in urlopen(url, data, timeout, cafile, capath, cadefault, context) 222 opener = _opener --> 223 return opener.open(url, data,第 224 章

/opt/conda/lib/python3.6/urllib/request.py in open(self, fullurl, data, timeout) 525 --> 526 response = self._open(req, data) 527

/opt/conda/lib/python3.6/urllib/request.py in _open(self, req, data) 543 result = self._call_chain(self.handle_open, protocol, protocol + --> 544 '_open', req) 545 如果結果:

/opt/conda/lib/python3.6/urllib/request.py in _call_chain(self, chain, kind, meth_name, *args) 503 func = getattr(handler, meth_name) --> 504 result = func(*args) 505 如果結果不是 None:

/opt/conda/lib/python3.6/urllib/request.py 在 https_open(self, req)
第1360章 1362

/opt/conda/lib/python3.6/urllib/request.py in do_open(self, http_class, req, **http_conn_args) 1319 除了 OSError 作為 err: # timeout error -> 1320 raise URLError(err) 1321 r = h .getresponse()

網址錯誤:

在處理上述異常的過程中,又發生了一個異常:

異常回溯(最近一次調用最后一次)在 () 4 import numpy as np 5 ----> 6 model = ResNet50(weights='imagenet', include_top=False)

ResNet50中的/opt/conda/lib/python3.6/site-packages/Keras-2.0.6-py3.6.egg/keras/applications/resnet50.py(包括_top,權重,input_tensor,input_shape,池化,類)261 WEIGHTS_PATH_NO_TOP, 262 cache_subdir='models', --> 263 md5_hash='a268eb855778b3df3c7506639542a6af') 264 model.load_weights(weights_path) 265 if K.backend(): ==

/opt/conda/lib/python3.6/site-packages/Keras-2.0.6-py3.6.egg/keras/utils/data_utils.py in get_file(fname, origin, untar, md5_hash, file_hash, cache_subdir, hash_algorithm ,extract,archive_format,cache_dir) 220 urlretrieve(origin, fpath, dl_progress) 221 除了 URLError 作為 e: --> 222 raise Exception(error_msg.format(origin, e.errno, e.reason)) 223 除了 HTTPError 作為 e: 224引發異常(error_msg.format(origin,e.code,e.msg))

例外: https : //github.com/fchollet/deep-learning-models/releases/download/v0.2/resnet50_weights_tf_dim_ordering_tf_kernels_notop.h5上的 URL 獲取失敗:無 -- [Errno -2] 名稱或服務未知

互聯網設置在 kaggle 上默認關閉。 如果你打開它,你可以下載預訓練的模型。

在內核的右側,您將看到可以在那里啟用 Internet 的設置。在此處輸入圖片說明

據我所知,Kaggle 內核在沒有 Internet 訪問的隔離容器中運行。 所有訓練模型都必須設置並附加為數據集。 您可以嘗試在公共數據集庫中搜索您需要的內容。 例如,可以在這里找到 Resnet50: https ://www.kaggle.com/keras/resnet50

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM