jax.numpy.shape#

jax.numpy.shape(a)[原始碼]#

傳回陣列的形狀。

參數:

a (array_like) – 輸入陣列。

傳回:

shape – 形狀元組的元素給出對應陣列維度的長度。

傳回類型:

整數元組

另請參閱

len

len(a) 對於 N 維陣列 (N>=1) 相當於 np.shape(a)[0]

ndarray.shape

等效的陣列方法。

範例

>>> import numpy as np
>>> np.shape(np.eye(3))
(3, 3)
>>> np.shape([[1, 3]])
(1, 2)
>>> np.shape([0])
(1,)
>>> np.shape(0)
()
>>> a = np.array([(1, 2), (3, 4), (5, 6)],
...              dtype=[('x', 'i4'), ('y', 'i4')])
>>> np.shape(a)
(3,)
>>> a.shape
(3,)