MCPcopy Create free account
hub / github.com/dmlc/dgl / train

Function train

examples/sparse/hypergraphatt.py:67–74  ·  view source on GitHub ↗
(model, optimizer, H, X, Y, train_mask)

Source from the content-addressed store, hash-verified

65
66
67def train(model, optimizer, H, X, Y, train_mask):
68 model.train()
69 Y_hat = model(H, X)
70 loss = F.cross_entropy(Y_hat[train_mask], Y[train_mask])
71 optimizer.zero_grad()
72 loss.backward()
73 optimizer.step()
74 return loss.item()
75
76
77def evaluate(model, H, X, Y, val_mask, test_mask, num_classes):

Callers 1

mainFunction · 0.70

Calls 4

trainMethod · 0.45
zero_gradMethod · 0.45
backwardMethod · 0.45
stepMethod · 0.45

Tested by

no test coverage detected