MCPcopy Create free account
hub / github.com/chengsen/PyTorch_TextGCN / val

Method val

trainer.py:184–203  ·  view source on GitHub ↗
(self, x, prefix="val")

Source from the content-addressed store, hash-verified

182
183 @th.no_grad()
184 def val(self, x, prefix="val"):
185 self.model.eval()
186 with th.no_grad():
187 logits = self.model.forward(self.features, self.adj)
188 loss = self.criterion(logits[x],
189 self.target[x])
190 acc = accuracy(logits[x],
191 self.target[x])
192 f1, precision, recall = macro_f1(logits[x],
193 self.target[x],
194 num_classes=self.nclass)
195
196 desc = {
197 f"{prefix}_loss": loss.item(),
198 "acc" : acc,
199 "macro_f1" : f1,
200 "precision" : precision,
201 "recall" : recall,
202 }
203 return desc
204
205 @th.no_grad()
206 def test(self):

Callers 2

trainMethod · 0.95
testMethod · 0.95

Calls 3

accuracyFunction · 0.90
macro_f1Function · 0.90
forwardMethod · 0.45

Tested by

no test coverage detected