chainer.utils.CooMatrix

class chainer.utils.CooMatrix(data, row, col, shape, order=None, requires_grad=False)[source]

A sparse matrix in COO format.

Parameters
  • data (N-dimensional array) – The entries of the matrix. The entries are usually non-zero-elements in the matrix.

  • row (N-dimensional array) – The row indices of the matrix entries.

  • col (N-dimensional array) – The column indices of the matrix entries.

  • shape (tuple of int) – The shape of the matrix in dense format.

  • order ('C', 'F', 'other' or None) – If 'C', the maxtix is assumed that its row indices are sorted. If 'F', the matrix is assumed that its column indices are sorted. If 'other', the matrix is assumed as neither ‘C’ order nor ‘F’ order. If None (this is the default), the matrix is automatically checked if it is ‘C’ order, ‘F’ order or another. This information will be used by some functions like sparse_matmul() as a hint to improve performance.

  • requires_grad (bool) – If True, gradient of this sparse matrix will be computed in back-propagation.

See also

See to_coo() for how to construct a COO matrix from an array.

Methods

to_dense()[source]

Returns a dense matrix format of this sparse matrix.

__eq__(value, /)

Return self==value.

__ne__(value, /)

Return self!=value.

__lt__(value, /)

Return self<value.

__le__(value, /)

Return self<=value.

__gt__(value, /)

Return self>value.

__ge__(value, /)

Return self>=value.