Skip to content

Training metrics #100

@rcmalli

Description

@rcmalli

Should we have training accuracy calculation automated?

Currently I am handling like this

class Model(ptl.LightningModule):

    def __init__(self,):
        super(AdvTrainModel, self).__init__()
        self.training_correct_counter = 0

    def training_step(self, batch, batch_nb):
        #...
        if batch_nb == 0:
            self.training_correct_counter = (torch.max(y_hat, 1)[1].view(y.size()) == y).sum()
        else:
            self.training_correct_counter += (torch.max(y_hat, 1)[1].view(y.size()) == y).sum()
        return {'loss': self.my_loss(y_adv_hat, y)}

    def validation_end(self, outputs):
        # ...
        train_avg_acc = 100 * self.training_correct_counter / len(self.tng_dataloader.dataset)
        return {'Training/_accuracy':train_avg_acc}

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureIs an improvement or enhancementhelp wantedOpen to be worked on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions