块堆叠的不同行为

时间:2019-07-16 14:24:06

标签: python numpy

也许这个问题是基本的。但这确实使我感到困惑,并导致了错误。

import numpy as np

list1 = [np.matrix([[0, 1]]), np.matrix([[0,1]])]
np.stack(list1)  # This gives matrix([[0, 1], [0, 1]]), which is expected

list2 = [np.matrix([[0.]]), np.matrix([[0.]])]
np.stack(list2)  # This gives matrix([[0., 0.]]). 
                 # But I thought this would output matrix([[0.], [0.]])

它有什么不同的行为?

0 个答案:

没有答案