Search code examples
pythontensorflowkerasmnist

Implementing Neural Nets with Keras


I am trying to implement this code in my computer, the problem I was facing is running the following code gives an error:

fashion_mnist = keras.datasets.fashion_mnist
(X_train_full, y_train_full), (X_test, y_test) = (fashion_mnist.load_data())
X_valid, X_train = X_train_full[:5000], X_train_full[5000:]
y_valid, y_train = y_train_full[:5000], y_train_full[5000:]

the error:

~\Anaconda3\lib\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)
    251         urlretrieve(origin, fpath, dl_progress)
    252       except HTTPError as e:
--> 253         raise Exception(error_msg.format(origin, e.code, e.msg))
    254       except URLError as e:
    255         raise Exception(error_msg.format(origin, e.errno, e.reason))

Exception: URL fetch failure on https://storage.googleapis.com/tensorflow/tf-keras-datasets/train-labels-idx1-ubyte.gz: 403 -- Forbidden

but If I tried to download the data separately it does not give an error of Forbidden, I tried to load the data without downloading it from Google but got another error

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-13-68fe7d0ac27a> in <module>
      1 fashion_mnist = keras.datasets.fashion_mnist
----> 2 (X_train_full, y_train_full), (X_test, y_test) = (fashion_mnist)
      3 X_valid, X_train = X_train_full[:5000], X_train_full[5000:]
      4 y_valid, y_train = y_train_full[:5000], y_train_full[5000:]

TypeError: cannot unpack non-iterable module object

In the end, I decided not to use load_data() method but still the same error, Is there any way to unpack and prepare the data from train-labels-idx1-ubyte without using the above method?

PS: I tried using a VPN but still responding Forbidden


Solution

  • If it's downloaded correctly, you need to specify your path.

    Have you tried (X_train_full, y_train_full), (X_test, y_test) = fashion_mnist.load_data (path="%yourLocalPath%") as documented Here ? tensorflow docs

    If it's not, The first error you got because you live in a place where TensorFlow is Forbidden, simply just use a VPN.