I am using the keras API to load in the MNIST dataset. My problem is I need to use AlexNet as my algorithm. Understanding the AlexNet model, I require to start with 277x277 images but the MINST dataset has 28x28. How can I reshape the numpy array so that each image is 227x277 to then use the full AlexNet model?

(x_train, y_train), (x_test, y_test) = tf.keras.datasets.mnist.load_data()

This is how I load my data in. Could someone show me the solution to change the initial images to match the AlexNet model?


You can use tf.image.resize, as follows:

(x_train, y_train), (_, _) = tf.keras.datasets.mnist.load_data()

print(x_trian.shape) # (60000, 28, 28)

# train set / data 
x_train = np.expand_dims(x_train, axis=-1)
x_train = tf.image.resize(x_train, [32,32]) # if we want to resize 

print(x_train.shape) # (60000, 32, 32, 1)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.