How can I reduce a dimension of a numpy array, then trim some from the end?

Shamoon :

I have a numpy array of shape (6, 100, 161). I want to convert it to (600, 161) and then trim 16 from the end, so it's (584, 161)?

warped :

You can call reshape followed by slicing

import numpy as np

a = np.zeros((6,100,161))

b = a.reshape(600,161)[:-16,:]

b.shape

out: (584,161)

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=3987&siteId=1