initial_model = VGG19(weights='imagenet', pooling = max)
我正在尝试在kaggle上的keras中导入预训练的VGG模型。我遇到了不熟悉的gaierror。
-------------------------------------------------- ---------------------------- gaierror追踪(最近的通话 最后)/opt/conda/lib/python3.6/urllib/request.py in do_open(self, http_class,req,** http_conn_args)1317
h.request(req.get_method(),req.selector,req.data,标头, -> 1318 encode_chunked = req.has_header('Transfer-encoding'))1319
除了OSError作为err:#超时错误/opt/conda/lib/python3.6/http/client.py in request(self,method,url, 正文,标题,encode_chunked)1238“”“发送完整 向服务器请求。“”“ -> 1239 self._send_request(方法,URL,正文,标头,encode_chunked)1240
_send_request中的/opt/conda/lib/python3.6/http/client.py(自身,方法, 网址,正文,标头,encode_chunked)1284正文= _encode(body,'body') -> 1285 self.endheaders(body,encode_chunked = encode_chunked)1286
/opt/conda/lib/python3.6/http/client.py in endheaders(self, message_body,encode_chunked)提高1233 CannotSendHeader() -> 1234 self._send_output(message_body,encode_chunked = encode_chunked)1235
_send_output中的/opt/conda/lib/python3.6/http/client.py message_body,encode_chunked)1025 del self._buffer [:] -> 1026 self.send(msg)1027
发送(自身,数据)中的/opt/conda/lib/python3.6/http/client.py 963如果self.auto_open: -> 964 self.connect() 965其他:
connect(self)1391中的/opt/conda/lib/python3.6/http/client.py -> 1392 super()。connect()1393
连接中的/opt/conda/lib/python3.6/http/client.py (935) -> 936(self.host,self.port),self.timeout,self.source_address) 937 self.sock.setsockopt(socket.IPPROTO_TCP,socket.TCP_NODELAY,1)
在create_connection中的/opt/conda/lib/python3.6/socket.py(地址, 超时,source_address) 703错误=无 -> 704 for getaddrinfo(主机,端口,0,SOCK_STREAM)中的res: 705 af,socktype,proto,canonname,sa = res
getaddrinfo中的/opt/conda/lib/python3.6/socket.py(主机,端口,家庭, 类型,原型,标志) 744 addrlist = [] -> 745 for _socket.getaddrinfo中的res(主机,端口,家庭,类型,原型,标志): 746 af,socktype,proto,canonname,sa = res
gaierror:[Errno -3]名称解析暂时失败
在处理上述异常期间,发生了另一个异常:
URLError跟踪(最近的呼叫 最后)/opt/conda/lib/python3.6/site-packages/keras/utils/data_utils.py 在get_file(fname,origin,untar,md5_hash,file_hash,cache_subdir, hash_algorithm,提取,archive_format,cache_dir) 221尝试: -> 222 urlretrieve(来源,fpath,dl_progress) 223,除了HTTPError为e:
/opt/conda/lib/python3.6/urllib/request.py in urlretrieve(url, 文件名,报告挂钩,数据) 247 -> 248,带有contextlib.closing(urlopen(url,data))as fp: 249个标头= fp.info()
urlopen中的/opt/conda/lib/python3.6/urllib/request.py(URL,数据, 超时,cafile,capath,cadefault,上下文) 222开瓶器= _opener -> 223返回opener.open(URL,数据,超时) 224
/opt/conda/lib/python3.6/urllib/request.py in open(self,fullurl, 数据,超时) 525 -> 526响应= self._open(req,data) 527
_open中的/opt/conda/lib/python3.6/urllib/request.py(自身,要求,数据) 第543章 -> 544'_open',req) 545,如果结果:
_call_chain中的/opt/conda/lib/python3.6/urllib/request.py(自身,链, 种类,meth_name,* args) 503 func = getattr(handler,meth_name) -> 504结果= func(* args) 505,如果结果不是None:
/opt/conda/lib/python3.6/urllib/request.py in https_open(self,req)
1360 return self.do_open(http.client.HTTPSConnection,req, -> 1361 context = self._context,check_hostname = self._check_hostname)1362/opt/conda/lib/python3.6/urllib/request.py in do_open(self, http_class,req,** http_conn_args)1319(OSError除外) 错误:#超时错误 -> 1320提高URLError(err)1321 r = h.getresponse()
URLError:
在处理上述异常期间,发生了另一个异常:
异常回溯(最近的呼叫 最后)在() ----> 1个initial_model = VGG19(include_top = False,input_shape =(128,128,3),weights ='imagenet')
/opt/conda/lib/python3.6/site-packages/keras/applications/ init .py 在包装器中(* args,** kwargs) 26 kwargs ['models'] =型号 27 kwargs ['utils'] = utils ---> 28 return base_fun(* args,** kwargs) 29 30个返回包装纸
/opt/conda/lib/python3.6/site-packages/keras/applications/vgg19.py在 VGG19(* args,** kwargs) 9 @keras_modules_injection 10 def VGG19(* args,** kwargs): ---> 11返回vgg19.VGG19(* args,** kwargs) 12 13
/opt/conda/lib/python3.6/site-packages/keras_applications/vgg19.py在 VGG19(include_top,权重,input_tensor,input_shape,合并, 类,** kwargs) 219 WEIGHTS_PATH_NO_TOP, 220 cache_subdir ='模型', -> 221 file_hash ='253f8cb515780f3b799900260a226db6') 222.load_weights(weights_path) 223 if backend.backend()=='theano':
/opt/conda/lib/python3.6/site-packages/keras/utils/data_utils.py在 get_file(fname,origin,untar,md5_hash,file_hash,cache_subdir, hash_algorithm,提取,archive_format,cache_dir) 224引发异常(error_msg.format(来源,e.code,e.msg)) 225,URLError除外,例如e: -> 226引发Exception(error_msg.format(origin,e.errno,e.reason)) 227除了(Exception,KeyboardInterrupt): 228如果os.path.exists(fpath):
异常:URL提取失败 https://github.com/fchollet/deep-learning-models/releases/download/v0.1/vgg19_weights_tf_dim_ordering_tf_kernels_notop.h5: 无-[Errno -3]名称解析暂时失败
答案 0 :(得分:0)
似乎您的内核中可能未启用Internet访问。您可以在右侧面板中执行此操作。添加互联网连接后,您就可以下载文件了。
我们实际上已经有the VGG-19 weights uploaded to Kaggle。如果愿意,您可以将现有数据集添加到内核中,而不是下载它,这可能对您来说会更快一些。
希望有帮助! :)
答案 1 :(得分:-2)
在右侧,您将看到一个名为“ Internet”的选项,检查它是否设置为“ On”。如果没有,请启用它,然后尝试。它应该可以工作