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 (numpy.ndarray or cupy.ndarray) – The entries of the matrix. The entries are usually non-zero-elements in the matrix. row (numpy.ndarray or cupy.ndarray) – The row indices of the matrix entries. col (numpy.ndarray or cupy.ndarray) – 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 to_coo() for how to construct a COO matrix from an array.
to_dense()[source]