import numpy as np
a = np.array([[1,2],[3,5]])
x = np.expand_dims(a, axis=0)
y = np.expand_dims(a, axis=1)
z = np.expand_dims(a, axis=2)
print(a.shape)
print(x.shape)
print(y.shape)
print(z.shape)
输出结果:

x:

y:

z:

参考知乎https://www.zhihu.com/question/265545749





参考:
https://blog.csdn.net/qq_40643699/article/details/107985401
