Data Science Asked by CrocusMac on March 5, 2021
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 277×277 images but the MINST dataset has 28×28. How can I reshape the numpy array so that each image is 227×277 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)
Answered by M.Innat on March 5, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP