[FIXED] Module: tf.keras.datasets. Set where (directory) to download the dataset


I’m using tf.keras.datasets to download CIFAR 10 dataset and I wondering where the images are downloaded.

I’ve been searching if there is a function to set where to download the images, but I haven’t found any. I have searched over the Internet and the only thing I have found is how to create my own dataset using Tensorflow.

My code is:

from tensorflow.keras import datasets

(train_images, train_labels), (test_images, test_labels) = datasets.cifar10.load_data()

# Normalize pixel values to be between 0 and 1
train_images, test_images = train_images / 255.0, test_images / 255.0

How can I set where to download the images before using the function load_data()?


According to the source, the output (train_images, train_labels), (test_images, test_labels) are "Tuple of Numpy arrays". Therefore, when you call load_data() they are loaded into your memory from their origin (https://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz). If you want to download them as well, you will have to do that separately on your own (some inspiration could be taken from here). Remember, the function name is load_data(), and not download_data(), where load refers to memory, and download refers to disk.

Answered By – Marcus

Answer Checked By – Timothy Miller (Easybugfix Admin)

Leave a Reply

(*) Required, Your email will not be published