m0_61104322 2022-01-08 15:36 采纳率: 89.5%
浏览 24
已结题

深度学习模型ALbert程序跑动时出现的问题

Albert进行文本分类时候出现的问题,我找到一些文章说是不能爬墙,但是换了别的浏览器,没有开V之后,照样出现了这个问题,麻烦大家帮忙解决一下:

module_url="https://tfhub.dev/tensorflow/albert_en_xlarge/1"
albert_layer = hub.KerasLayer(module_url, trainable=True)

--------------------------------------------------------------------------
ConnectionResetError                      Traceback (most recent call last)
/environment/miniconda3/lib/python3.7/urllib/request.py in do_open(self, http_class, req, **http_conn_args)
   1349                 h.request(req.get_method(), req.selector, req.data, headers,
-> 1350                           encode_chunked=req.has_header('Transfer-encoding'))
   1351             except OSError as err: # timeout error

/environment/miniconda3/lib/python3.7/http/client.py in request(self, method, url, body, headers, encode_chunked)
   1276         """Send a complete request to the server."""
-> 1277         self._send_request(method, url, body, headers, encode_chunked)
   1278 

/environment/miniconda3/lib/python3.7/http/client.py in _send_request(self, method, url, body, headers, encode_chunked)
   1322             body = _encode(body, 'body')
-> 1323         self.endheaders(body, encode_chunked=encode_chunked)
   1324 

/environment/miniconda3/lib/python3.7/http/client.py in endheaders(self, message_body, encode_chunked)
   1271             raise CannotSendHeader()
-> 1272         self._send_output(message_body, encode_chunked=encode_chunked)
   1273 

/environment/miniconda3/lib/python3.7/http/client.py in _send_output(self, message_body, encode_chunked)
   1031         del self._buffer[:]
-> 1032         self.send(msg)
   1033 

/environment/miniconda3/lib/python3.7/http/client.py in send(self, data)
    971             if self.auto_open:
--> 972                 self.connect()
    973             else:

/environment/miniconda3/lib/python3.7/http/client.py in connect(self)
   1446             self.sock = self._context.wrap_socket(self.sock,
-> 1447                                                   server_hostname=server_hostname)
   1448 

/environment/miniconda3/lib/python3.7/ssl.py in wrap_socket(self, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, session)
    422             context=self,
--> 423             session=session
    424         )

/environment/miniconda3/lib/python3.7/ssl.py in _create(cls, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, context, session)
    869                         raise ValueError("do_handshake_on_connect should not be specified for non-blocking sockets")
--> 870                     self.do_handshake()
    871             except (OSError, ValueError):

/environment/miniconda3/lib/python3.7/ssl.py in do_handshake(self, block)
   1138                 self.settimeout(None)
-> 1139             self._sslobj.do_handshake()
   1140         finally:

ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

URLError                                  Traceback (most recent call last)
/tmp/ipykernel_18269/2136896962.py in <module>
      1 module_url="https://tfhub.dev/tensorflow/albert_en_xlarge/1"
----> 2 albert_layer = hub.KerasLayer(module_url, trainable=True)

/environment/miniconda3/lib/python3.7/site-packages/tensorflow_hub/keras_layer.py in __init__(self, handle, trainable, arguments, _sentinel, tags, signature, signature_outputs_as_dict, output_key, output_shape, load_options, **kwargs)
    151 
    152     self._load_options = load_options
--> 153     self._func = load_module(handle, tags, self._load_options)
    154     self._has_training_argument = func_has_training_argument(self._func)
    155     self._is_hub_module_v1 = getattr(self._func, "_is_hub_module_v1", False)

/environment/miniconda3/lib/python3.7/site-packages/tensorflow_hub/keras_layer.py in load_module(handle, tags, load_options)
    447       except ImportError:  # Expected before TF2.4.
    448         set_load_options = load_options
--> 449     return module_v2.load(handle, tags=tags, options=set_load_options)
    450 
    451 

/environment/miniconda3/lib/python3.7/site-packages/tensorflow_hub/module_v2.py in load(handle, tags, options)
     90   if not isinstance(handle, str):
     91     raise ValueError("Expected a string, got %s" % handle)
---> 92   module_path = resolve(handle)
     93   is_hub_module_v1 = tf.io.gfile.exists(
     94       native_module.get_module_proto_path(module_path))

/environment/miniconda3/lib/python3.7/site-packages/tensorflow_hub/module_v2.py in resolve(handle)
     45     A string representing the Module path.
     46   """
---> 47   return registry.resolver(handle)
     48 
     49 

/environment/miniconda3/lib/python3.7/site-packages/tensorflow_hub/registry.py in __call__(self, *args, **kwargs)
     49     for impl in reversed(self._impls):
     50       if impl.is_supported(*args, **kwargs):
---> 51         return impl(*args, **kwargs)
     52       else:
     53         fails.append(type(impl).__name__)

/environment/miniconda3/lib/python3.7/site-packages/tensorflow_hub/compressed_module_resolver.py in __call__(self, handle)
     66 
     67     return resolver.atomic_download(handle, download, module_dir,
---> 68                                     self._lock_file_timeout_sec())
     69 
     70   def _lock_file_timeout_sec(self):

/environment/miniconda3/lib/python3.7/site-packages/tensorflow_hub/resolver.py in atomic_download(handle, download_fn, module_dir, lock_file_timeout_sec)
    416     logging.info("Downloading TF-Hub Module '%s'.", handle)
    417     tf.compat.v1.gfile.MakeDirs(tmp_dir)
--> 418     download_fn(handle, tmp_dir)
    419     # Write module descriptor to capture information about which module was
    420     # downloaded by whom and when. The file stored at the same level as a

/environment/miniconda3/lib/python3.7/site-packages/tensorflow_hub/compressed_module_resolver.py in download(handle, tmp_dir)
     61       request = urllib.request.Request(
     62           self._append_compressed_format_query(handle))
---> 63       response = self._call_urlopen(request)
     64       return resolver.DownloadManager(handle).download_and_uncompress(
     65           response, tmp_dir)

/environment/miniconda3/lib/python3.7/site-packages/tensorflow_hub/resolver.py in _call_urlopen(self, request)
    520     # Overriding this method allows setting SSL context in Python 3.
    521     if self._context is None:
--> 522       return urllib.request.urlopen(request)
    523     else:
    524       return urllib.request.urlopen(request, context=self._context)

/environment/miniconda3/lib/python3.7/urllib/request.py in urlopen(url, data, timeout, cafile, capath, cadefault, context)
    220     else:
    221         opener = _opener
--> 222     return opener.open(url, data, timeout)
    223 
    224 def install_opener(opener):

/environment/miniconda3/lib/python3.7/urllib/request.py in open(self, fullurl, data, timeout)
    523             req = meth(req)
    524 
--> 525         response = self._open(req, data)
    526 
    527         # post-process response

/environment/miniconda3/lib/python3.7/urllib/request.py in _open(self, req, data)
    541         protocol = req.type
    542         result = self._call_chain(self.handle_open, protocol, protocol +
--> 543                                   '_open', req)
    544         if result:
    545             return result

/environment/miniconda3/lib/python3.7/urllib/request.py in _call_chain(self, chain, kind, meth_name, *args)
    501         for handler in handlers:
    502             func = getattr(handler, meth_name)
--> 503             result = func(*args)
    504             if result is not None:
    505                 return result

/environment/miniconda3/lib/python3.7/urllib/request.py in https_open(self, req)
   1391         def https_open(self, req):
   1392             return self.do_open(http.client.HTTPSConnection, req,
-> 1393                 context=self._context, check_hostname=self._check_hostname)
   1394 
   1395         https_request = AbstractHTTPHandler.do_request_

/environment/miniconda3/lib/python3.7/urllib/request.py in do_open(self, http_class, req, **http_conn_args)
   1350                           encode_chunked=req.has_header('Transfer-encoding'))
   1351             except OSError as err: # timeout error
-> 1352                 raise URLError(err)
   1353             r = h.getresponse()
   1354         except:

URLError: <urlopen error [Errno 104] Connection reset by peer>


  • 写回答

1条回答 默认 最新

  • CSDN专家-HGJ 2022-01-08 21:46
    关注

    网页连接超时,被重置,检查一下网址,看看用浏览器可否打开,不行就用代理。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论 编辑记录

报告相同问题?

问题事件

  • 系统已结题 1月17日
  • 已采纳回答 1月9日
  • 创建了问题 1月8日

悬赏问题

  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法