maxframe.tensor.shape#

maxframe.tensor.shape(a)[源代码]#

返回一个张量的形状。

参数:

a (array_like) -- 输入张量。

返回:

shape -- 形状元组中的元素给出了相应数组维度的长度。

返回类型:

ExecutableTuple of tensors

示例

>>> import maxframe.tensor as mt
>>> mt.shape(mt.eye(3)).execute()
(3, 3)
>>> mt.shape([[1, 2]]).execute()
(1, 2)
>>> mt.shape([0]).execute()
(1,)
>>> mt.shape(0).execute()
()
>>> a = mt.array([(1, 2), (3, 4)], dtype=[('x', 'i4'), ('y', 'i4')])
>>> mt.shape(a).execute()
(2,)