Error running second codes cell of C1W3 Lab 1

Hi experts,

When running the C1W3 Lab 1, 2nd codes cell:

mnist = tf.keras.datasets.mnist

(x_train, y_train),(x_test, y_test) = mnist.load_data()
x_train, x_test = x_train / 255.0, x_test / 255.0

caused errors:

Downloading data from https://storage.googleapis.com/tensorflow/tf-keras-datasets/mnist.npz

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

/opt/conda/lib/python3.7/http/client.py in request(self, method, url, body, headers, encode_chunked)
   1251         """Send a complete request to the server."""
-> 1252         self._send_request(method, url, body, headers, encode_chunked)
   1253 

/opt/conda/lib/python3.7/http/client.py in _send_request(self, method, url, body, headers, encode_chunked)
   1297             body = _encode(body, 'body')
-> 1298         self.endheaders(body, encode_chunked=encode_chunked)
   1299 

/opt/conda/lib/python3.7/http/client.py in endheaders(self, message_body, encode_chunked)
   1246             raise CannotSendHeader()
-> 1247         self._send_output(message_body, encode_chunked=encode_chunked)
   1248 

/opt/conda/lib/python3.7/http/client.py in _send_output(self, message_body, encode_chunked)
   1025         del self._buffer[:]
-> 1026         self.send(msg)
   1027 

/opt/conda/lib/python3.7/http/client.py in send(self, data)
    965             if self.auto_open:
--> 966                 self.connect()
    967             else:

/opt/conda/lib/python3.7/http/client.py in connect(self)
   1413 
-> 1414             super().connect()
   1415 

/opt/conda/lib/python3.7/http/client.py in connect(self)
    937         self.sock = self._create_connection(
--> 938             (self.host,self.port), self.timeout, self.source_address)
    939         self.sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)

/opt/conda/lib/python3.7/socket.py in create_connection(address, timeout, source_address)
    727         try:
--> 728             raise err
    729         finally:

/opt/conda/lib/python3.7/socket.py in create_connection(address, timeout, source_address)
    715                 sock.bind(source_address)
--> 716             sock.connect(sa)
    717             # Break explicitly a reference cycle

OSError: [Errno 99] Cannot assign requested address

During handling of the above exception, another exception occurred:

URLError                                  Traceback (most recent call last)
/opt/conda/lib/python3.7/site-packages/tensorflow_core/python/keras/utils/data_utils.py in get_file(fname, origin, untar, md5_hash, file_hash, cache_subdir, hash_algorithm, extract, archive_format, cache_dir)
    263       try:
--> 264         urlretrieve(origin, fpath, dl_progress)
    265       except HTTPError as e:

/opt/conda/lib/python3.7/urllib/request.py in urlretrieve(url, filename, reporthook, data)
    246 
--> 247     with contextlib.closing(urlopen(url, data)) as fp:
    248         headers = fp.info()

/opt/conda/lib/python3.7/urllib/request.py in urlopen(url, data, timeout, cafile, capath, cadefault, context)
    221         opener = _opener
--> 222     return opener.open(url, data, timeout)
    223 

/opt/conda/lib/python3.7/urllib/request.py in open(self, fullurl, data, timeout)
    524 
--> 525         response = self._open(req, data)
    526 

/opt/conda/lib/python3.7/urllib/request.py in _open(self, req, data)
    542         result = self._call_chain(self.handle_open, protocol, protocol +
--> 543                                   '_open', req)
    544         if result:

/opt/conda/lib/python3.7/urllib/request.py in _call_chain(self, chain, kind, meth_name, *args)
    502             func = getattr(handler, meth_name)
--> 503             result = func(*args)
    504             if result is not None:

/opt/conda/lib/python3.7/urllib/request.py in https_open(self, req)
   1361             return self.do_open(http.client.HTTPSConnection, req,
-> 1362                 context=self._context, check_hostname=self._check_hostname)
   1363 

/opt/conda/lib/python3.7/urllib/request.py in do_open(self, http_class, req, **http_conn_args)
   1320             except OSError as err: # timeout error
-> 1321                 raise URLError(err)
   1322             r = h.getresponse()

URLError: <urlopen error [Errno 99] Cannot assign requested address>

During handling of the above exception, another exception occurred:

Exception                                 Traceback (most recent call last)
<ipython-input-6-95eb1c3cd4db> in <module>
      1 mnist = tf.keras.datasets.mnist
      2 
----> 3 (x_train, y_train),(x_test, y_test) = mnist.load_data()
      4 x_train, x_test = x_train / 255.0, x_test / 255.0

/opt/conda/lib/python3.7/site-packages/tensorflow_core/python/keras/datasets/mnist.py in load_data(path)
     48       origin=origin_folder + 'mnist.npz',
     49       file_hash=
---> 50       '731c5ac602752760c8e48fbffcf8c3b850d9dc2a2aedcf2cc48468fc17b673d1')
     51   with np.load(path, allow_pickle=True) as f:
     52     x_train, y_train = f['x_train'], f['y_train']

/opt/conda/lib/python3.7/site-packages/tensorflow_core/python/keras/utils/data_utils.py in get_file(fname, origin, untar, md5_hash, file_hash, cache_subdir, hash_algorithm, extract, archive_format, cache_dir)
    266         raise Exception(error_msg.format(origin, e.code, e.msg))
    267       except URLError as e:
--> 268         raise Exception(error_msg.format(origin, e.errno, e.reason))
    269     except (Exception, KeyboardInterrupt) as e:
    270       if os.path.exists(fpath):

Exception: URL fetch failure on https://storage.googleapis.com/tensorflow/tf-keras-datasets/mnist.npz: None -- [Errno 99] Cannot assign requested address

Have tried re-opened the notebook but same error when executing same codes cell.

Any idea what needs fixing?

Thanks,
MCW

Hi @Mun_Chung_Wong

The link for the dataset is correct, but if the dataset cannot be fetched, it my be a potential issue with the network or environment where the code is being executed.

Try running the provided code snippet locally, if this runs without any errors, then the cloud notebook session might have some network issues that need to be reported.

Hope it helps!

Ok thanks I will try running locally then.

[UPDATE]
Works locally … now the C1W3 assignment runs into same issue.

Tested the assignment locally and happy with the result, should I just go
ahead and submit it? Will the grading process throws error and fail me for
the underlying issue?

Thanks,
MCW

1 Like

hi @chris.favila

I think there is an issue ongoing with this, so notifying you, if this need to updated or corrected.

i suppose the same issue was noticed DLS course.

Regards
DP

Lucky the assignment grading isn’t affected although exhibiting same errors.

Thanks,
MCW

2 Likes

Hi everyone. Thank you for reporting. We’ve followed up with Coursera re: this issue. Will place a workaround for now while it’s being fixed. Will update this thread as soon as it’s ready. Thanks!

Hi! The labs are now updated and shouldn’t require an external download of the MNIST dataset. You can relaunch from the classroom to see the changes. Thank you!

1 Like