MCPcopy
hub / github.com/black0017/MedicalZooPytorch / validate_epoch

Method validate_epoch

lib/train/trainer.py:75–89  ·  view source on GitHub ↗
(self, epoch)

Source from the content-addressed store, hash-verified

73 self.writer.display_terminal(self.len_epoch, epoch, mode='train', summary=True)
74
75 def validate_epoch(self, epoch):
76 self.model.eval()
77
78 for batch_idx, input_tuple in enumerate(self.valid_data_loader):
79 with torch.no_grad():
80 input_tensor, target = prepare_input(input_tuple=input_tuple, args=self.args)
81 input_tensor.requires_grad = False
82
83 output = self.model(input_tensor)
84 loss, per_ch_score = self.criterion(output, target)
85
86 self.writer.update_scores(batch_idx, loss.item(), per_ch_score, 'val',
87 epoch * self.len_epoch + batch_idx)
88
89 self.writer.display_terminal(len(self.valid_data_loader), epoch, mode='val', summary=True)

Callers 1

trainingMethod · 0.95

Calls 3

prepare_inputFunction · 0.90
update_scoresMethod · 0.80
display_terminalMethod · 0.45

Tested by

no test coverage detected