maxframe.tensor.atleast_1d#
- maxframe.tensor.atleast_1d(*tensors)[源代码]#
将输入转换为至少一维的张量。
标量输入会被转换为一维张量,而高维输入则保持不变。
- 参数:
tensors1 (array_like) -- 一个或多个输入张量。
tensors2 (array_like) -- 一个或多个输入张量。
... (array_like) -- 一个或多个输入张量。
- 返回:
ret —— 一个张量或张量列表,每个张量都满足
a.ndim >= 1。仅在必要时才会进行复制。- 返回类型:
Tensor
参见
示例
>>> import maxframe.tensor as mt
>>> mt.atleast_1d(1.0).execute() array([ 1.])
>>> x = mt.arange(9.0).reshape(3,3) >>> mt.atleast_1d(x).execute() array([[ 0., 1., 2.], [ 3., 4., 5.], [ 6., 7., 8.]]) >>> mt.atleast_1d(x) is x True
>>> mt.atleast_1d(1, [3, 4]).execute() [array([1]), array([3, 4])]