Boltzmachine:

self.weight = F.softmax(self.weight.relu(), dim=1)


I am not sure of the context on what you are trying to achieve.
I guess, you do not need to assign self.weight again. It is already learnable and it will accumulate gradients when you backpropagate.