I have a 5-d numpy array, the shape is (5, 1000, 32, 32, 3), which means there are 3 channels of 32*32 pixels, and 1000 samples, 5 different timestamps. How do I print specific 32*32 data, for example, I want to print the 32*32 data from 16th sample, 2nd timestamp, 1st channel?
asked May 27, 2019 at 17:29
HAO CHEN
1,3493 gold badges18 silver badges33 bronze badges
-
index is 0 based. so [1, 15, :, :, 0]yosukesabai– yosukesabai2019年05月27日 17:32:23 +00:00Commented May 27, 2019 at 17:32
1 Answer 1
With a mix of inedexing and slicing this can be done like this:
arr = np.random.randint(1000, size=(5, 1000, 32, 32, 3))
result = arr[1, 15, :, :, 0]
print(result.shape)
This will output the shape of the result:
(32, 32)
Sign up to request clarification or add additional context in comments.
Comments
lang-py