@torch.no_grad()
def test():
model.eval()
data = dataset[0]
data = data.to(device)
optimizer.zero_grad()
logits = model(data.x, data.edge_index)
accs = []
for _, mask in data("train_mask", "val_mask", "test_mask"):
pred = logits[mask].max(1)[1]
acc = pred.eq(data.y[mask]).sum().item() / mask.sum().item()
accs.append(acc)return accs
best_val_acc = test_acc = 0
for epoch in range(1, 201):
After Change
for data in test_loader:
data = data.to(device)
logits = model(data.x, data.edge_index)
pred = logits.argmax(dim=1)
masks = [data.train_mask, data.val_mask, data.test_mask]
for i, mask in enumerate(masks):
total_correct[i] += (pred[mask] == data.y[mask]).sum().item()
total_nodes[i] += mask.sum().item()
return (torch.Tensor(total_correct) / torch.Tensor(total_nodes)).tolist()