0

I have a blob with dimensions ( N, C, H, W) and i want to reshape it into (N, H, W, C). Directly reshaping hasn't been much helpful. Can someone help please??

  • 2
    Does this answer your question? [Swapping the dimensions of a numpy array](https://stackoverflow.com/questions/23943379/swapping-the-dimensions-of-a-numpy-array) – user202729 Jan 31 '21 at 07:13
  • Not sure what [tag:blob] have to do here. You probably have a `numpy.ndarray`. – user202729 Jan 31 '21 at 07:13
  • Do you just want to reshape or actually 'swapaxes'? – lalala Jan 31 '21 at 07:13
  • Yeah, i needed to swap axis only. Also added blob because people who have worked with blob must regularly deal with this. So it could help in future too. Thanks for the help – Messsyy Jan 31 '21 at 09:24

1 Answers1

1

transpose it:

In [344]: X = np.ones((2,3,4,5),int)
In [345]: X.transpose(0,2,3,1).shape
Out[345]: (2, 4, 5, 3)
hpaulj
  • 221,503
  • 14
  • 230
  • 353