MCPcopy Create free account
hub / github.com/PolymathicAI/AstroCLIP / validation_step

Method validation_step

astroclip/models/moco_v2.py:220–236  ·  view source on GitHub ↗
(self, batch, batch_idx)

Source from the content-addressed store, hash-verified

218 return loss
219
220 def validation_step(self, batch, batch_idx):
221 # in STL10 we pass in both lab+unl for online ft
222 if self.trainer.datamodule.name == "stl10":
223 # labeled_batch = batch[1]
224 unlabeled_batch = batch[0]
225 batch = unlabeled_batch
226
227 (img_1, img_2), labels = batch
228
229 output, target, keys = self(img_q=img_1, img_k=img_2, queue=self.val_queue)
230 self._dequeue_and_enqueue(
231 keys, queue=self.val_queue, queue_ptr=self.val_queue_ptr
232 ) # dequeue and enqueue
233
234 loss = F.cross_entropy(output, target.long())
235 results = {"val_loss": loss}
236 return results
237
238 def validation_epoch_end(self, outputs):
239 log = {"val_loss": val_loss, "val_acc1": val_acc1, "val_acc5": val_acc5}

Callers

nothing calls this directly

Calls 1

_dequeue_and_enqueueMethod · 0.95

Tested by

no test coverage detected