我正在尝试将零填充到列表中多个向量的末尾。但是,我在网上发现的只是填充一个numpy向量。因此,我很困惑如何填充列表中的多个向量/数组。
The shape of my data looks like the following: I basically want to pad zeros in the
end, so that each vector/array have the same length
[(12220,),
(24479,),
(26468,),
(12233,),
...
(24453,),
(12220,),
(24453,)]
玩具数据示例:
a = [np.array([1, 2, 3, 6, 4]),
np.array([2, 3, 1]),
np.array([5, 5, 5, 5]),
np.array([1, 1])]
我想要实现的最终结果是:
[[ 1. 2. 3. 6. 4.]
[ 2. 3. 1. 0. 0.]
[ 5. 5. 5. 5. 0.]
[ 1. 1. 0. 0. 0.]]