I’m not sure, but I have a feeling that using the same function might make the autograd history graph incorrect. Instead of using self.mean try calling torch.mean (same for var, sqrt, etc - basically erase the entire init) and see if you still get the problem…