MCPcopy Create free account
hub / github.com/pytorch/tutorials / validation_step

Method validation_step

intermediate_source/mnist_train_nas.py:103–110  ·  view source on GitHub ↗
(self, batch, batch_idx)

Source from the content-addressed store, hash-verified

101 return loss
102
103 def validation_step(self, batch, batch_idx):
104 x, y = batch
105 logits = self(x)
106 loss = F.nll_loss(logits, y)
107 preds = torch.argmax(logits, dim=1)
108 acc = multiclass_accuracy(preds, y, num_classes=self.num_classes)
109 self.log("val_acc", acc, prog_bar=False)
110 return loss
111
112 def configure_optimizers(self):
113 optimizer = torch.optim.Adam(self.parameters(), lr=self.learning_rate)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected