import torch class TorchGraphInterface(object): def __init__(self): pass @staticmethod def convert_sparse_mat_to_tensor(X): coo = X.tocoo() i = torch.LongTensor([coo.row, coo.col]) v = torch.from_numpy(coo.data).float() return torch.sparse.FloatTensor(i, v, coo.shape)