解析np.stack的各类用法
众所周知,numpy是一个强大的库,其中stack()就用于矩阵间的堆叠。
以下有np.hstack(),np.vstack(),np.stack(,axis=0),np.stack(,axis=1),np.stack(,axis=2)的用法解析。
import numpy as np
a = np.arange(1,7).reshape((2,3))
b = np.arange(7,13).reshape((2,3))
c = np.arange(13,19).reshape((2,3))
a
>>>array([[1, 2, 3],
[4, 5, 6]])
b
>>>array([[ 7, 8, 9],
[10