Skip to content

Correct way to implement custom metrics - Tensors keep filling up #390

Answered by justusschock
cemde asked this question in Q&A
Discussion options

You must be logged in to vote

Hi,

First, those are only emptied after a call to .reset() (which is automated within lightning), not after every call to compute.

Second: I would suggest to use lists for you state, since you are concatenating tensors which can be a memory allocating operation (not necessary at that time). So probably you could go with self.add_state("preds", default=[], dist_reduce_fx="cat") and self.preds.append(preds) instead.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@cemde
Comment options

@justusschock
Comment options

Answer selected by justusschock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants