MCPcopy Create free account
hub / github.com/MarcCoru/locationencoder / validation_step

Method validation_step

locationencoder/imageencoder.py:37–49  ·  view source on GitHub ↗
(self, batch, batch_idx)

Source from the content-addressed store, hash-verified

35 return loss
36
37 def validation_step(self, batch, batch_idx):
38 images, _, labels, _ = batch
39 loss, output = self.common_step(batch, batch_idx)
40
41 prec1 = top_k_accuracy_score(labels.cpu(), output.cpu(), labels=np.arange(output.shape[1]), k=1)
42 acc = accuracy_score(y_true=labels.cpu(), y_pred=output.argmax(1).cpu()) # should be same as prec1
43 prec3 = top_k_accuracy_score(labels.cpu(), output.cpu(), labels=np.arange(output.shape[1]), k=3)
44
45 self.log("val_prec1", prec1)
46 self.log("val_acc", acc)
47 self.log("val_prec3", prec3)
48 self.log("val_loss", loss)
49 return loss
50
51 def test_step(self, batch, batch_idx):
52 return self.common_step(batch, batch_idx)

Callers

nothing calls this directly

Calls 1

common_stepMethod · 0.95

Tested by

no test coverage detected