Skip to content

Sparse and array helpers

Conversions between dense, sparse and scipy representations, sparse softmax and indexing helpers.

Function Description
to_scipy_sparse_matrix() Converts a graph given by edge_index (and optional scalar edge features) to a scipy.sparse.coo_matrix.
from_scipy_sparse_matrix() Converts a scipy.sparse matrix (or array) to an edge_index and edge weights.
dense_to_sparse() Converts a dense adjacency matrix, or a batch of them, to an edge_index and edge weights (the non-zero entries).
softmax()
mask_to_index() Converts a boolean mask to the indices of its True entries (the inverse of index_to_mask()).
cumsum() Cumulative sum of x along axis, with a leading zero: the output has one more element than x along axis (e.g. to turn counts into pointers/offsets).
select() Selects the entries of src along axis given by an index array or by a boolean mask.
narrow() Returns the length entries of src along axis starting at start.