Skip to main content
deleted 126 characters in body
Source Link

Gogasca's answer worked for me with a little adjustment. For Python 3.9, changing the code in ~/Library/Python/3.9/lib/python/site-packages/keras/datasets/mnist.py so that it uses the path variable as full path instead of adding the origin_folder makes it possible to pass any local path to the downloaded file.

  1. Download the file: https://storage.googleapis.com/tensorflow/tf-keras-datasets/mnist.npz

  2. Put it in ~/Library/Python/3.9/lib/python/site-packages/keras/datasets/, or another location to Your liking.

    Download the file: https://storage.googleapis.com/tensorflow/tf-keras-datasets/mnist.npz
  3. Alter ~/Library/Python/3.9/lib/python/site-packages/keras/datasets/mnist.py

    path = path """ added this line, commented out origin_folder and previous path initilization""" """ origin_folder = 'https://storage.googleapis.com/tensorflow/tf-keras-datasets/' """ """ path = get_file( path, origin=origin_folder + 'mnist.npz', file_hash= '731c5ac602752760c8e48fbffcf8c3b850d9dc2a2aedcf2cc48468fc17b673d1') """ with np.load(path, allow_pickle=True) as f: # pylint: disable=unexpected-keyword-arg x_train, y_train = f['x_train'], f['y_train'] x_test, y_test = f['x_test'], f['y_test']

    return (x_train, y_train), (x_test, y_test)

    Put it in ~/Library/Python/3.9/lib/python/site-packages/keras/datasets/, or another location to Your liking.
  4. use the following code to load data:

    path = "/Users/username/Library/Python/3.9/lib/python/site-packages/keras/datasets/mnist.npz" (train_images, train_labels), (test_images, test_labels ) = mnist.load_data(path=path)

    Alter ~/Library/Python/3.9/lib/python/site-packages/keras/datasets/mnist.py
path = path

""" origin_folder = 'https://storage.googleapis.com/tensorflow/tf-keras-datasets/' """
""" path = get_file(
path,origin=origin_folder + 'mnist.npz',file_hash='731c5ac602752760c8e48fbffcf8c3b850d9dc2a2aedcf2cc48468fc17b673d1') """

with np.load(path, allow_pickle=True) as f:  # pylint:
    disable=unexpected-keyword-arg
    x_train, y_train = f['x_train'], f['y_train']
    x_test, y_test = f['x_test'], f['y_test']
return (x_train, y_train), (x_test, y_test)
  1. use the following code to load data:
path = "/Users/username/Library/Python/3.9/lib/python/site-packages/keras/datasets/mnist.npz"
(train_images, train_labels), (test_images, test_labels ) = mnist.load_data(path=path)```

Gogasca's answer worked for me with a little adjustment. For Python 3.9, changing the code in ~/Library/Python/3.9/lib/python/site-packages/keras/datasets/mnist.py so that it uses the path variable as full path instead of adding the origin_folder makes it possible to pass any local path to the downloaded file.

  1. Download the file: https://storage.googleapis.com/tensorflow/tf-keras-datasets/mnist.npz

  2. Put it in ~/Library/Python/3.9/lib/python/site-packages/keras/datasets/, or another location to Your liking.

  3. Alter ~/Library/Python/3.9/lib/python/site-packages/keras/datasets/mnist.py

    path = path """ added this line, commented out origin_folder and previous path initilization""" """ origin_folder = 'https://storage.googleapis.com/tensorflow/tf-keras-datasets/' """ """ path = get_file( path, origin=origin_folder + 'mnist.npz', file_hash= '731c5ac602752760c8e48fbffcf8c3b850d9dc2a2aedcf2cc48468fc17b673d1') """ with np.load(path, allow_pickle=True) as f: # pylint: disable=unexpected-keyword-arg x_train, y_train = f['x_train'], f['y_train'] x_test, y_test = f['x_test'], f['y_test']

    return (x_train, y_train), (x_test, y_test)

  4. use the following code to load data:

    path = "/Users/username/Library/Python/3.9/lib/python/site-packages/keras/datasets/mnist.npz" (train_images, train_labels), (test_images, test_labels ) = mnist.load_data(path=path)

Gogasca's answer worked for me with a little adjustment. For Python 3.9, changing the code in ~/Library/Python/3.9/lib/python/site-packages/keras/datasets/mnist.py so that it uses the path variable as full path instead of adding the origin_folder makes it possible to pass any local path to the downloaded file.

  1. Download the file: https://storage.googleapis.com/tensorflow/tf-keras-datasets/mnist.npz
  2. Put it in ~/Library/Python/3.9/lib/python/site-packages/keras/datasets/, or another location to Your liking.
  3. Alter ~/Library/Python/3.9/lib/python/site-packages/keras/datasets/mnist.py
path = path

""" origin_folder = 'https://storage.googleapis.com/tensorflow/tf-keras-datasets/' """
""" path = get_file(
path,origin=origin_folder + 'mnist.npz',file_hash='731c5ac602752760c8e48fbffcf8c3b850d9dc2a2aedcf2cc48468fc17b673d1') """

with np.load(path, allow_pickle=True) as f:  # pylint:
    disable=unexpected-keyword-arg
    x_train, y_train = f['x_train'], f['y_train']
    x_test, y_test = f['x_test'], f['y_test']
return (x_train, y_train), (x_test, y_test)
  1. use the following code to load data:
path = "/Users/username/Library/Python/3.9/lib/python/site-packages/keras/datasets/mnist.npz"
(train_images, train_labels), (test_images, test_labels ) = mnist.load_data(path=path)```
Source Link

Gogasca's answer worked for me with a little adjustment. For Python 3.9, changing the code in ~/Library/Python/3.9/lib/python/site-packages/keras/datasets/mnist.py so that it uses the path variable as full path instead of adding the origin_folder makes it possible to pass any local path to the downloaded file.

  1. Download the file: https://storage.googleapis.com/tensorflow/tf-keras-datasets/mnist.npz

  2. Put it in ~/Library/Python/3.9/lib/python/site-packages/keras/datasets/, or another location to Your liking.

  3. Alter ~/Library/Python/3.9/lib/python/site-packages/keras/datasets/mnist.py

    path = path """ added this line, commented out origin_folder and previous path initilization""" """ origin_folder = 'https://storage.googleapis.com/tensorflow/tf-keras-datasets/' """ """ path = get_file( path, origin=origin_folder + 'mnist.npz', file_hash= '731c5ac602752760c8e48fbffcf8c3b850d9dc2a2aedcf2cc48468fc17b673d1') """ with np.load(path, allow_pickle=True) as f: # pylint: disable=unexpected-keyword-arg x_train, y_train = f['x_train'], f['y_train'] x_test, y_test = f['x_test'], f['y_test']

    return (x_train, y_train), (x_test, y_test)

  4. use the following code to load data:

    path = "/Users/username/Library/Python/3.9/lib/python/site-packages/keras/datasets/mnist.npz" (train_images, train_labels), (test_images, test_labels ) = mnist.load_data(path=path)