jax.numpy.diag_indices_from#
- jax.numpy.diag_indices_from(arr)[源代码][源代码]#
返回用于访问给定数组主对角线的索引。
JAX 实现的
numpy.diag_indices_from()
。示例
>>> arr = jnp.array([[1, 2, 3], ... [4, 5, 6], ... [7, 8, 9]]) >>> jnp.diag_indices_from(arr) (Array([0, 1, 2], dtype=int32), Array([0, 1, 2], dtype=int32)) >>> arr = jnp.array([[[1, 2], [3, 4]], ... [[5, 6], [7, 8]]]) >>> jnp.diag_indices_from(arr) (Array([0, 1], dtype=int32), Array([0, 1], dtype=int32), Array([0, 1], dtype=int32))