Home > Enterprise >  Return a numpy array with third dimension representing multiple feature to only have the feature I w
Return a numpy array with third dimension representing multiple feature to only have the feature I w

Time:03-10

I have a numpy array of shape (samples, sequence_length, number_of_features) e.g. (10000, 1024, 2)

I want to break this down into (10000, 1024, 1) where I am only taking the first feature - what is the most efficient way of doing this with numpy without unravelling the array?

CodePudding user response:

Try this:

np.take(arr, indices=[0], axis=2)
  • Related