Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chapter 16: Downloading Shakespeare model: I get exception downloading the shakespeare_model #123

Open
efakinpelu opened this issue Feb 27, 2024 · 1 comment

Comments

@efakinpelu
Copy link

Thanks for helping us improve this project!

Before you create this issue
Please make sure you are using the latest updated code and libraries: see https://github.com/ageron/handson-ml3/blob/main/INSTALL.md#update-this-project-and-its-libraries

Also please make sure to read the FAQ (https://github.com/ageron/handson-ml3#faq) and search for existing issues (both open and closed), as your question may already have been answered: https://github.com/ageron/handson-ml3/issues

Describe what is unclear to you
Please provide a clear and concise description of what the problem is, and specify the notebook name and the cell number at which the problem occurs (or the chapter and page in the book).

To Reproduce
If the question relates to a specific piece of code, please copy the code that fails here, using code blocks like this:

def inverse(x):
    return 1 / x

result = inverse(0)

And if you get an exception, please copy the full stacktrace here:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 2, in inverse
ZeroDivisionError: division by zero

Expected behavior
If applicable, a clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Versions (please complete the following information):

  • OS: [e.g. MacOSX 10.15.7]
  • Python: [e.g. 3.7]
  • TensorFlow: [e.g., 2.4.1]
  • Scikit-Learn: [e.g., 0.24.1]
  • Other libraries that may be connected with the issue: [e.g., gym 0.18.0]

Additional context
Add any other context about the problem here.

@efakinpelu efakinpelu changed the title Chapter 16: Downloading Shakespeare model: Chapter 16: Downloading Shakespeare model: I get exception downloading the shakespeare_model Feb 27, 2024
@efakinpelu
Copy link
Author

Here's the code as I ran it:
import tensorflow as tf
from pathlib import Path

extra code – downloads a pretrained model

url = "https://github.com/ageron/data/raw/main/shakespeare_model.tgz"
path = tf.keras.utils.get_file("shakespeare_model.tgz", url, extract=True)
model_path = Path(path).with_name("shakespeare_model")
#shakespeare_model = tf.keras.models.load_model(model_path)

The stack trace I got:
Downloading data from https://github.com/ageron/data/raw/main/shakespeare_model.tgz

TimeoutError Traceback (most recent call last)
File ~\anaconda3\envs\bdl\lib\urllib\request.py:1346, in AbstractHTTPHandler.do_open(self, http_class, req, **http_conn_args)
1345 try:
-> 1346 h.request(req.get_method(), req.selector, req.data, headers,
1347 encode_chunked=req.has_header('Transfer-encoding'))
1348 except OSError as err: # timeout error

File ~\anaconda3\envs\bdl\lib\http\client.py:1285, in HTTPConnection.request(self, method, url, body, headers, encode_chunked)
1284 """Send a complete request to the server."""
-> 1285 self._send_request(method, url, body, headers, encode_chunked)

File ~\anaconda3\envs\bdl\lib\http\client.py:1331, in HTTPConnection._send_request(self, method, url, body, headers, encode_chunked)
1330 body = _encode(body, 'body')
-> 1331 self.endheaders(body, encode_chunked=encode_chunked)

File ~\anaconda3\envs\bdl\lib\http\client.py:1280, in HTTPConnection.endheaders(self, message_body, encode_chunked)
1279 raise CannotSendHeader()
-> 1280 self._send_output(message_body, encode_chunked=encode_chunked)

File ~\anaconda3\envs\bdl\lib\http\client.py:1040, in HTTPConnection._send_output(self, message_body, encode_chunked)
1039 del self._buffer[:]
-> 1040 self.send(msg)
1042 if message_body is not None:
1043
1044 # create a consistent interface to message_body

File ~\anaconda3\envs\bdl\lib\http\client.py:980, in HTTPConnection.send(self, data)
979 if self.auto_open:
--> 980 self.connect()
981 else:

File ~\anaconda3\envs\bdl\lib\http\client.py:1454, in HTTPSConnection.connect(self)
1452 server_hostname = self.host
-> 1454 self.sock = self._context.wrap_socket(self.sock,
1455 server_hostname=server_hostname)

File ~\anaconda3\envs\bdl\lib\ssl.py:501, in SSLContext.wrap_socket(self, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, session)
495 def wrap_socket(self, sock, server_side=False,
496 do_handshake_on_connect=True,
497 suppress_ragged_eofs=True,
498 server_hostname=None, session=None):
499 # SSLSocket class handles server_hostname encoding before it calls
500 # ctx._wrap_socket()
--> 501 return self.sslsocket_class._create(
502 sock=sock,
503 server_side=server_side,
504 do_handshake_on_connect=do_handshake_on_connect,
505 suppress_ragged_eofs=suppress_ragged_eofs,
506 server_hostname=server_hostname,
507 context=self,
508 session=session
509 )

File ~\anaconda3\envs\bdl\lib\ssl.py:1074, in SSLSocket._create(cls, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, context, session)
1073 raise ValueError("do_handshake_on_connect should not be specified for non-blocking sockets")
-> 1074 self.do_handshake()
1075 except (OSError, ValueError):

File ~\anaconda3\envs\bdl\lib\ssl.py:1343, in SSLSocket.do_handshake(self, block)
1342 self.settimeout(None)
-> 1343 self._sslobj.do_handshake()
1344 finally:

TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

During handling of the above exception, another exception occurred:

URLError Traceback (most recent call last)
File ~\anaconda3\envs\bdl\lib\site-packages\keras\utils\data_utils.py:296, in get_file(fname, origin, untar, md5_hash, file_hash, cache_subdir, hash_algorithm, extract, archive_format, cache_dir)
295 try:
--> 296 urlretrieve(origin, fpath, DLProgbar())
297 except urllib.error.HTTPError as e:

File ~\anaconda3\envs\bdl\lib\site-packages\keras\utils\data_utils.py:84, in urlretrieve(url, filename, reporthook, data)
82 break
---> 84 response = urlopen(url, data)
85 with open(filename, "wb") as fd:

File ~\anaconda3\envs\bdl\lib\urllib\request.py:214, in urlopen(url, data, timeout, cafile, capath, cadefault, context)
213 opener = _opener
--> 214 return opener.open(url, data, timeout)

File ~\anaconda3\envs\bdl\lib\urllib\request.py:523, in OpenerDirector.open(self, fullurl, data, timeout)
522 meth = getattr(processor, meth_name)
--> 523 response = meth(req, response)
525 return response

File ~\anaconda3\envs\bdl\lib\urllib\request.py:632, in HTTPErrorProcessor.http_response(self, request, response)
631 if not (200 <= code < 300):
--> 632 response = self.parent.error(
633 'http', request, response, code, msg, hdrs)
635 return response

File ~\anaconda3\envs\bdl\lib\urllib\request.py:555, in OpenerDirector.error(self, proto, *args)
554 args = (dict, proto, meth_name) + args
--> 555 result = self._call_chain(*args)
556 if result:

File ~\anaconda3\envs\bdl\lib\urllib\request.py:494, in OpenerDirector._call_chain(self, chain, kind, meth_name, *args)
493 func = getattr(handler, meth_name)
--> 494 result = func(*args)
495 if result is not None:

File ~\anaconda3\envs\bdl\lib\urllib\request.py:747, in HTTPRedirectHandler.http_error_302(self, req, fp, code, msg, headers)
745 fp.close()
--> 747 return self.parent.open(new, timeout=req.timeout)

File ~\anaconda3\envs\bdl\lib\urllib\request.py:517, in OpenerDirector.open(self, fullurl, data, timeout)
516 sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method())
--> 517 response = self._open(req, data)
519 # post-process response

File ~\anaconda3\envs\bdl\lib\urllib\request.py:534, in OpenerDirector._open(self, req, data)
533 protocol = req.type
--> 534 result = self._call_chain(self.handle_open, protocol, protocol +
535 '_open', req)
536 if result:

File ~\anaconda3\envs\bdl\lib\urllib\request.py:494, in OpenerDirector._call_chain(self, chain, kind, meth_name, *args)
493 func = getattr(handler, meth_name)
--> 494 result = func(*args)
495 if result is not None:

File ~\anaconda3\envs\bdl\lib\urllib\request.py:1389, in HTTPSHandler.https_open(self, req)
1388 def https_open(self, req):
-> 1389 return self.do_open(http.client.HTTPSConnection, req,
1390 context=self._context, check_hostname=self._check_hostname)

File ~\anaconda3\envs\bdl\lib\urllib\request.py:1349, in AbstractHTTPHandler.do_open(self, http_class, req, **http_conn_args)
1348 except OSError as err: # timeout error
-> 1349 raise URLError(err)
1350 r = h.getresponse()

URLError: <urlopen error [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond>

During handling of the above exception, another exception occurred:

Exception Traceback (most recent call last)
Cell In[2], line 6
4 # extra code – downloads a pretrained model
5 url = "https://github.com/ageron/data/raw/main/shakespeare_model.tgz"
----> 6 path = tf.keras.utils.get_file("shakespeare_model.tgz", url, extract=True)
7 model_path = Path(path).with_name("shakespeare_model")

File ~\anaconda3\envs\bdl\lib\site-packages\keras\utils\data_utils.py:300, in get_file(fname, origin, untar, md5_hash, file_hash, cache_subdir, hash_algorithm, extract, archive_format, cache_dir)
298 raise Exception(error_msg.format(origin, e.code, e.msg))
299 except urllib.error.URLError as e:
--> 300 raise Exception(error_msg.format(origin, e.errno, e.reason))
301 except (Exception, KeyboardInterrupt):
302 if os.path.exists(fpath):

Exception: URL fetch failure on https://github.com/ageron/data/raw/main/shakespeare_model.tgz: None -- [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

Please what am I doing wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant