m0_61104322
2022-01-08 15:36
采纳率: 88.2%
浏览 21

深度学习模型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条回答 默认 最新

相关推荐 更多相似问题