m0_61104322 2022-01-08 15:36 采纳率: 92.3%
浏览 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日

悬赏问题

  • ¥15 请问读取环境变量文件失败是什么原因?
  • ¥15 在若依框架下实现人脸识别
  • ¥15 网络科学导论,网络控制
  • ¥100 安卓tv程序连接SQLSERVER2008问题
  • ¥15 利用Sentinel-2和Landsat8做一个水库的长时序NDVI的对比,为什么Snetinel-2计算的结果最小值特别小,而Lansat8就很平均
  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载