def on_validation_epoch_end(self, trainer, pl_module):
     node_emb = th.cat(self.val_outputs, 0)
     g = trainer.datamodule.g
     labels = g.ndata['labels']
     f1_micro, f1_macro = compute_acc(
         node_emb, labels, trainer.datamodule.train_nid,
         trainer.datamodule.val_nid, trainer.datamodule.test_nid)
     pl_module.log('val_f1_micro', f1_micro)
def evaluate(model, g, nfeat, labels, train_nids, val_nids, test_nids, device):
    """
    Evaluate the model on the validation set specified by ``val_mask``.
    g : The entire graph.
    inputs : The features of all the nodes.
    labels : The labels of all the nodes.
    val_mask : A 0-1 mask indicating which nodes do we actually compute the accuracy for.
    device : The GPU device to evaluate on.
    """
    model.eval()
    with th.no_grad():
        # single gpu
        if isinstance(model, SAGE):
            pred = model.inference(g, nfeat, device, args.batch_size,
                                   args.num_workers)
        # multi gpu
        else:
            pred = model.module.inference(g, nfeat, device, args.batch_size,
                                          args.num_workers)
    model.train()
    return compute_acc(pred, labels, train_nids, val_nids, test_nids)