Return the number of dimensions of an array.
JAX implementation of numpy.ndim()
. Unlike np.ndim
, this function raises a TypeError
if the input is a collection such as a list or tuple.
a (ArrayLike | SupportsNdim) – array-like object, or any object with an ndim
attribute.
An integer specifying the number of dimensions of a
.
Examples
Number of dimensions for arrays:
>>> x = jnp.arange(10) >>> jnp.ndim(x) 1 >>> y = jnp.ones((2, 3)) >>> jnp.ndim(y) 2
This also works for scalars:
For arrays, this can also be accessed via the jax.Array.ndim
property:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.3