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

Function train_step

examples/graphbolt/disk_based_feature/node_classification.py:139–148  ·  view source on GitHub ↗
(minibatch, optimizer, model, loss_fn)

Source from the content-addressed store, hash-verified

137
138
139def train_step(minibatch, optimizer, model, loss_fn):
140 node_features = minibatch.node_features["feat"]
141 labels = minibatch.labels
142 optimizer.zero_grad()
143 out = model(minibatch.blocks, node_features)
144 loss = loss_fn(out, labels)
145 num_correct = accuracy(out, labels) * labels.size(0)
146 loss.backward()
147 optimizer.step()
148 return loss.detach(), num_correct, labels.size(0)
149
150
151def train_helper(

Callers 1

train_helperFunction · 0.70

Calls 5

accuracyFunction · 0.70
zero_gradMethod · 0.45
sizeMethod · 0.45
backwardMethod · 0.45
stepMethod · 0.45

Tested by

no test coverage detected