n_kotel:


What is the problem which causes such an error?
What is the correct way to use nn.Parameter to encapsulate it in other functions?




The problem is that you only compute self.b once - in the __init__. Then on the first backward, it’ll work. But the next time around, the edge in the computation graph connecting self.b to self.a will be gone.
The most obvious way to get this to work is to move the line self.b = torch.log(self.a) from the __init__ to the top of the forwrd.
This comes up every once in a while 15, but it’s not important enough/the workaround is good enough so it is not a priority.

Best regards
Thomas