Changing graph dataset matrices from sparse format to dense

Viewed 45

I am trying to use the CoRA dataset to train a graph neural network on tensorflow for the first time. The features and adjacency matrices provided by the dataset comes in a sparse representation but I don't need it here. Thus, I want to use numpy's todense() but it turns out it doesn't exist. For your reference, here is the relevant code:

import tensorflow as tf
import numpy as np
from spektral.datasets import citation

cora_dataset = spektral.datasets.citation.Citation(name='cora')
test_mask = cora_dataset.mask_te
train_mask = cora_dataset.mask_tr
val_mask = cora_dataset.mask_va
graph = cora_dataset.graphs[0]
features = graph.x
adj = graph.a
labels = graph.y

features = features.todense()

and the error is: "AttributeError: 'numpy.ndarray' object has no attribute 'todense'"

I would like to know if there has been a replacement for todense() or any other ways to convert sparse representations to dense.

0 Answers
Related