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

Categories

0 votes
780 views
in Technique[技术] by (71.8m points)

keras - Is there any way to resize an images present in an array of images

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

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

1 Answer

0 votes
by (71.8m points)
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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...