Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Return a numpy array with third dimension representing multiple feature to only have the feature I want

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Try this:

np.take(arr, indices=[0], axis=2)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading