1

I have a numpy array, arr, of shape(1000, 400, 56)

For context, 400 represents the time bins, 56 represents a motion vector. 1000 is the nr of samples

For each sample, I want to split the array (the 400, 56 part) in a grid like fashion. For example I want 4, 200, 28. Where the 28 part for each sample is from splitting the motion vector in half and placing it in one of the 4 samples separately (note in this case the time would have been split in half also).

The problem with doing reshape(4, 200, 28) is that it splits the 56 into x2 28 and places them right after the other consecutively (in the same sample array) which is undesired. I want the first half of the 56 to be in one sample array and the second half to be in another sample array such that the x56 motion vector is split in half.

What's the best way to do this?

5
  • Permute first and rearrange to be 1000, 56,400 then reshape (1000, 4 , 28,200) then rearrange again (1000, 4, 200, 28) is that what you want? Commented Nov 5, 2022 at 16:01
  • 1
    As far as i understand this post should solve your problem: stackoverflow.com/questions/65467809/… Commented Nov 5, 2022 at 16:01
  • @amirhm unfortunately not, it seems to create arrays that are all over the place (I confirmed with plotting also) Commented Nov 5, 2022 at 16:43
  • 2
    It would be easier if you provided a minimal reproducible example. With smaller size, obviously. So an example arr and an example output after splitting. Commented Nov 5, 2022 at 17:07
  • 1
    A first step is reshape the (1000, 400, 56) to (1000,2,200,2,28). Then use transpose or swapaxes to get a (1000,2,2,200,28). Then a final reshape. Commented Nov 5, 2022 at 17:57

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.