Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

i have an image data present in format of (1449,640,480,3) i want to resize my images before giving it to CNN. i can resize them by extracting every single image and then group them in an array but it would take alot of time and RAM. is there any way (using tensorflow, or keras or any other library ) to resize it.

question from:https://stackoverflow.com/questions/65880140/is-there-any-way-to-resize-an-images-present-in-an-array-of-images

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
794 views
Welcome To Ask or Share your Answers For Others

1 Answer

import keras
from keras.datasets import mnist
(train_images, train_labels), (test_images, test_labels) = mnist.load_data()

I have just loaded the mnist library for giving example. If we see the shape of the train_images.

train_images.shape
> (60000, 28, 28)

So its a 3D array where we have 60000 images with 28×28 shaped images. We can convert this 28×28 2D images to 1D images of 784(28×28).

train_images = train_images.reshape((60000, 28 * 28))
train_images.shape
> (60000, 784)

Hope it helped.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...