简体   繁体   中英

How can I split a numpy array into two new numpy arrays with different sizes?

I am very new to coding and I have a question about numpy arrays. So I have data stored in a numpy array (40, 512, 752, 1) , so 40 images of size 512 by 752 with one channnel, and i want to divide this into two arrays of (36, 512,752,1) and (4,512,752,1) . Does anyone know how I can do this or the code I can use?

Kind regards!

If you don't care about random selection:

image1 = images[:36, ...]
image2 = images[36:, ...]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM