I found the method of resizing the MNIST training dataset from (60000, 28, 28) to (60000, 14, 14).
This is the code and results:
import tensorflow as tf
import numpy as np
(x_train, y_train), (x_test, y_test) = tf.keras.datasets.mnist.load_data()
x_train, x_test = x_train[..., np.newaxis], x_test[..., np.newaxis]
x_train_small = tf.image.resize(x_train, (14,14)).numpy()
x_test_small = tf.image.resize(x_test, (14,14)).numpy()
print(x_train.shape)
print(x_test.shape)
print(x_train_small.shape)
print(x_test_small.shape)
>>>(60000, 28, 28, 1)
>>>(10000, 28, 28, 1)
>>>(60000, 14, 14, 1)
>>>(10000, 14, 14, 1)
- I'm confused about why it has to add a new axis to change the shape that I want.
- I would like to know whether there is another method to do the resize work without adding a new axis.