Save-Load-Infer with DGL

Dear all,

Let say I have trained the model and save and load it with this commands, PATH) and load it again, PATH). If I have a new graph and want to its nodes by using the loaded trained model, how should I proceed it?

I tried to find a similar demo or example, but couldn’t find it at this point.


1 Like

If you are confident that the model should generalize to the new graph, then just create a separate dataset class for this new graph and apply the model as for the training dataset.

If your model is transductive – the model architecture is tied to the graph it is trained on, then it cannot generalize to graph with unseen nodes. Otherwise, we say the model is inductive and can be tested on a different graph than what it is trained on. One such example is, where it trains a GAT on some graphs but tests it on others.

Thanks both,

Once I load the model with
trained_model = th.load("./model/")
And perform inference with
inference = trained_model(G_Infer_dgl, G_Infer_dgl.ndata["feature"].cuda())

Is there a way to know the precision or recall of my inference? or the precision or recall of my model?


Here is an example of how to run save/model for infer with DGL, though the code is not merged into DGL repo.

Specifically, you can look at and for model save and restore.

Thanks @classicsong,

But I’m looking for a command now to calculate precision and recall when we do node classification. An example of how im looking for is in How to get a better model