2021年2月3日星期三

How to break a list into couple lists

Assume that I have a list with size=(8,64,1,60,60) and want to break it into (4,2,64,1,60,60) and then sum them up along axis 1. I tried the code below but it raised with error : 'list' object has no attribute 'reshape'.

Please note that I want to keep the predictions as a list and do not want to change it to array.

predictions=list(np.random.randint(5,size=(8,64,1,60,60)))  predictions_sum = predictions.reshape(4,2, *predictions.shape[1:]).sum(axis=1)  
https://stackoverflow.com/questions/66038809/how-to-break-a-list-into-couple-lists February 04, 2021 at 11:03AM

没有评论:

发表评论