Skip to content
Discussion options

You must be logged in to vote

@sachinruk Class based metrics have been revamped! Please checkout the documentation for the new interface.
While the metrics package does not directly integrate with the accumulate_grad_batches argument (yet), you should be able to do something like this now:

def training_step(self, batch, batch_idx):
    x, y = batch
    y_hat = self(x)

    self.accuracy.update(y_hat.argmax(dim=-1), y)
    if self.trainer.accumulate_grad_batches % self.global_step == 0:
        accumulated_val = self.accuracy.compute()
        self.log('acc_accumulate', accumulated_val)
    ...

Closing this for now.

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by carmocca
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #3217 on February 04, 2021 23:42.