我已經好幾個小時strugling明白,爲什麼我不能夠做到這一點:附加一個numpy.array存儲在列表中的某個numpy.array
>>> import numpy as np
>>> a = [np.empty((0,78,3)) for i in range(2)]
>>> b = np.random.randint(10,size=(1,78,3))
>>> a[0] = np.append(a[0],[b],axis=0)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/numpy/lib/function_base.py", line 5003, in append
return concatenate((arr, values), axis=axis)
ValueError: all the input arrays must have same number of dimensions
>>>
a
是空的numpy的列表形狀的陣列(0,78,3)
b
是形狀隨機numpy.array(1,78,3)
然後我嘗試添加b
到a[0]
...但這並不似乎有可能因爲沒有相同的維度?..我不是sur呃這裏有什麼問題..如果我刪除了清單部分,它會工作,所以爲什麼不與清單?..
只需在追加時從b刪除[]。 'a [0] = np.append(a [0],b,axis = 0)' – Kochoba