【发布时间】:2017-03-04 08:52:12
【问题描述】:
我想通过循环将一个 numpy 数组(矩阵)附加到一个数组中
data=[[2 2 2] [3 3 3]]
Weights=[[4 4 4] [4 4 4] [4 4 4]]
All=np.array([])
for i in data:
#i=[2 2 2 ] #for example
h=i*Weights
#h=[[8 8 8][8 8 8][8 8 8]]
All=np.concatenate((All,h),axis=0)
我得到这个错误:
ValueError: all the input arrays must have same number of dimensions
我希望“All”变量为
[[8 8 8][8 8 8][8 8 8] [12 12 12][12 12 12][12 12 12]]
如何通过循环将“h”添加到“All”?
【问题讨论】:
标签: python arrays numpy matrix append