Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Explaination for what tensorflow.keras.dataset.minst.load_data() returns

I came across the statement:

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

and its corresponding explanation for what it returns:

Returns: 2 tuples: x_train, x_test: uint8 array of grayscale image data with shape (num_samples, 28, 28). y_train, y_test: uint8 array of digit labels (integers in range 0-9) with shape (num_samples,).

My doubt here is that whether x_train, x_test, y_train or y_test is itself a tuple that holds the values (num_sample, 28, 28) and (num_sample) respectively? and the tuple x_train, x_test is actually a tuple of tuple ?

I am new to this topic, so I am sorry if I am asking very silly questions! If anyone out there has an explanation for this, please write back.

like image 991
Sneha Sridharan Avatar asked Feb 03 '26 02:02

Sneha Sridharan


1 Answers

Let's look at the shapes of those objects:

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

print(np.shape(x_train))
print(np.shape(x_test))
print(np.shape(y_train))
print(np.shape(x_test))

(60000, 28, 28)

(10000, 28, 28)

(60000,)

(10000,)

You x_* datasets contain respectively 60000 and 10000 matrices of 28*28 pixels encoded as ints between 0 and 255.

Your y_* dataset contain the labels of what number is represented in your corresponding 28*28 pixels matrices.

like image 180
Thomas Schillaci Avatar answered Feb 04 '26 16:02

Thomas Schillaci



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!