Hi, I think I have found the problem. After I use the backward, I use the network’s forward to get some other values.



Gradient cannot be computed, help!


            loss.backward()

            # check if the weights are updated
            a = list(self.value.model.parameters())[0].clone()
            optimizer.zero_grad()
            optimizer.step()
            b = list(self.value.model.parameters())[0].clone()
            print("Weights Updated: ", not torch.equal(a.data, b.data))

            # compute the expectation of h of g
            e_v = self.e_vio(trajs) # I used forward of the model
> ```



Which may cause the weights to change (I am not sure). Basically, my steps are the following:

backwork, updates the weights
forward, may change the weights (not sure)
Is there a way to avoid this?
Thanks,