I have a matrix of size (21, 15, 50)
and I want to take the last level of the matrix which would be a size (1, 15, 50)
and I want to copy that matrix slice and paste it back to the original so then the original matrix would have a size of (22, 15, 50)
. This would result in slices 21 and 22 to have the same values.
I have tried np.hstack()
and append()
but I could be using them incorrectly.
What is the syntax for this? Thank you!
I call your 3d array is a
.
This code may solve your problem:
a = np.concatenate((a, a[-1,:,:].reshape(1,15,50)), axis=0)
I have tried and checked the shape of a, the result is (22,15,50)
as you want.
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.