def on_batch_end(self, state: State): """Records the confusion matrix at the end of each batch. Args: state (State): current state """ outputs = state.output[self.output_key] targets = state.input[self.input_key] confusion_matrix = utils.calculate_confusion_matrix_from_tensors( outputs, targets) if self.confusion_matrix is None: self.confusion_matrix = confusion_matrix else: self.confusion_matrix += confusion_matrix
def on_batch_end(self, runner: IRunner): """Records the confusion matrix at the end of each batch. Args: runner: current runner """ outputs = runner.output[self.output_key] targets = runner.input[self.input_key] confusion_matrix = utils.calculate_confusion_matrix_from_tensors( outputs, targets) if self.confusion_matrix is None: self.confusion_matrix = confusion_matrix else: self.confusion_matrix += confusion_matrix