chainerx.eye

chainerx.eye(N, M=None, k=0, dtype=float64, device=None)

Returns a 2-D array with ones on the diagonals and zeros elsewhere.

Parameters
  • N (int) – Number of rows.

  • M (int) – Number of columns. M == N by default.

  • k (int) – Index of the diagonal. Zero indicates the main diagonal, a positive index an upper diagonal, and a negative index a lower diagonal.

  • dtype – Data type.

  • device (Device) – Device on which the array is allocated. If omitted, the default device is chosen.

Returns

A 2-D array with given diagonals filled with ones and zeros elsewhere.

Return type

ndarray

See also

numpy.eye()