[英]Converting a 3D matrix into vertically cascaded 1D arrays
Is there any shortcut to the for loop in the following piece of code?下面这段代码中是否有for循环的快捷方式?
import numpy as np
ff = np.zeros((3,3,4))
gg = np.zeros((36,1))
ff[:,:,0] = 1
ff[:,:,1] = 2
ff[:,:,2] = 3
ff[:,:,3] = 4
for ii in xrange(4):
gg[ii*9:(ii+1)*9,0] = ff[:,:,ii].reshape((9,))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.