numpy array reshape question

Let's say that I have image data with shape $(32, 32, 3)$ and $50000$

  1. If I would like to reshape it to $(50000, 3, 32, 32)$ what should I do?

I tried np.transpose(0, 3, 1, 2) but it failed.

  1. If I would like to print the number $3$ from $(50000, 3, 32, 32)$ what should I do?

Topic image-preprocessing reshape numpy

Category Data Science


If image is a numpy object:

image = image.reshape((50000,3,32,32))

and then print:

print(image[:,3,:,:])

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.