原文:https://docs.scipy.org/doc/numpy/reference/generated/numpy.atleast_3d.html
校对:(虚位以待)
numpy.
atleast_3d
(*arys)[source]将输入视为至少包含三个维度的数组。
参数: | arys1,arys2,...:array_like
|
---|---|
返回: | res1,res2,...:ndarray
|
也可以看看
例子
>>> np.atleast_3d(3.0)
array([[[ 3.]]])
>>> x = np.arange(3.0)
>>> np.atleast_3d(x).shape
(1, 3, 1)
>>> x = np.arange(12.0).reshape(4,3)
>>> np.atleast_3d(x).shape
(4, 3, 1)
>>> np.atleast_3d(x).base is x
True
>>> for arr in np.atleast_3d([1, 2], [[1, 2]], [[[1, 2]]]):
... print(arr, arr.shape)
...
[[[1]
[2]]] (1, 2, 1)
[[[1]
[2]]] (1, 2, 1)
[[[1 2]]] (1, 1, 2)