Python: How can I reshape 3D Images (np array) to 1D and then reshape them back correctly to 3D?

Viewed 12577

I have RGB images (32 x 32 x 3) saved as 3D numpy arrays which I use as input for my Neural Net (using tensorflow). In order to use them as an input I reshape them to a 1D np array (1 x 3072) using reshape(1,-1). When I finish training my Net I want to reshape the output back, but using reshape(32,32,3) doesn't seem to provide the desired outcome.

Is this the correct way to do it? How I can be sure that each datum will be back to the correct place?

2 Answers
Related