def test_epoch_end(self, _): epoch_metric = f1_score(self.test_epoch_labels, self.test_epoch_predictions) self.log('Test Epoch F1', epoch_metric, prog_bar=True) self.test_epoch_labels = [] self.test_epoch_predictions = []
def validation_epoch_end(self, _): epoch_metric = f1_score(self.val_epoch_labels, self.val_epoch_predictions) self.log('Val Epoch F1', epoch_metric, prog_bar=True) self.val_epoch_labels = [] self.val_epoch_predictions = []
def training_epoch_end(self, _): epoch_metric = f1_score(self.train_epoch_labels, self.train_epoch_predictions) self.log('Train Epoch F1', epoch_metric, prog_bar=True) self.train_epoch_labels = [] self.train_epoch_predictions = []
def training_step(self, batch, _): input_ids, labels, attention_mask, words_ids = batch loss = self.__step(input_ids, labels, attention_mask, words_ids, 'train') metric = f1_score(self.train_epoch_labels, self.train_epoch_predictions) self.log('Train Step F1', metric, prog_bar=True) return loss
def test_step(self, batch, _): input_ids, labels, attention_mask, words_ids = batch loss = self.__step(input_ids, labels, attention_mask, words_ids, 'test') metric = f1_score(self.test_epoch_labels, self.test_epoch_predictions) self.log('Test Step F1', metric, prog_bar=True) self.log("Test Loss", loss, prog_bar=True) return loss
def validation_step(self, batch, _): input_ids, labels, attention_mask, words_ids = batch loss = self.__step(input_ids, labels, attention_mask, words_ids, 'val') metric = f1_score(self.val_epoch_labels, self.val_epoch_predictions) self.log('Val Step F1', metric, prog_bar=True) self.log("Val Loss", loss, prog_bar=True) return loss