MCPcopy Index your code
hub / github.com/JetBrains-Research/code2seq / _shared_epoch_end

Method _shared_epoch_end

code2seq/model/code2class.py:81–88  ·  view source on GitHub ↗
(self, outputs: EPOCH_OUTPUT, step: str)

Source from the content-addressed store, hash-verified

79 # ========== ON EPOCH END ==========
80
81 def _shared_epoch_end(self, outputs: EPOCH_OUTPUT, step: str):
82 assert isinstance(outputs, dict)
83 with torch.no_grad():
84 mean_loss = torch.stack([out[f"{step}/loss"] for out in outputs]).mean()
85 accuracy = self.__metrics[f"{step}_acc"].compute()
86 log = {f"{step}/loss": mean_loss, f"{step}/accuracy": accuracy}
87 self.__metrics[f"{step}_acc"].reset()
88 self.log_dict(log, on_step=False, on_epoch=True)
89
90 def training_epoch_end(self, outputs: EPOCH_OUTPUT):
91 self._shared_epoch_end(outputs, "train")

Callers 3

training_epoch_endMethod · 0.95
validation_epoch_endMethod · 0.95
test_epoch_endMethod · 0.95

Calls

no outgoing calls

Tested by 1

test_epoch_endMethod · 0.76