Closed imayachita closed 4 years ago
Hi,
for the PPI data the format is identical to the transductive case because the binary masks identify different components (disconnected subgraphs). You can reuse the same code as for the GCN example, although this will not be efficient, or you can use the masks to cut the adjacency matrix and node features into training, val and test graphs:
from spektral.datasets import graphsage
a, x, y, mask_tr, mask_va, mask_te = graphsage.load_data('PPI')
a_tr = a[mask_tr, :][:, mask_tr]
x_tr = x[mask_tr]
y_tr = y[mask_tr]
# same for *_te and *_va
Once you have your data split up, it will be sufficient to feed the matrices to the model, it doesn't matter if the size changes (just make sure that the "batch size" is high enough -- otherwise Keras will try to batch the rows of your graph and you don't want that):
model.fit([x_tr, a_tr], y_tr, batch_size=y_tr.shape[0], validation_data=([x_va, a_va], y_va))
model.evaluate([x_te, a_te], y_te, batch_size=y_te.shape[0])
Hope this helps. Cheers
It seems to work. Thanks!
Hi @danielegrattarola, I have been trying to dig into Spektral and I wonder if it is possible to do Inductive Learning using GAT and GraphSAGE, for example on PPI dataset? I have looked at the examples here https://graphneural.network/examples/, but it seems to me that those are all Transductive Learning because the
model.evaluate
andmodel.predict
need the Adjacency Matrix and Node Features Matrix of the same size with the ones we feed in tomodel.fit
. How can I do prediction for Node Classification task on an entirely new graph with different size?Thank you very much!