prior = Variable(torch.zeros(24), requires_grad=True)
prior_param = [nn.Parameter(prior.data)]
h_test = torch.autograd.grad(outputs=prior.mean(), inputs=prior_param) #does not work
h_test = torch.autograd.grad(outputs=prior.mean(), inputs=prior) #works
I want to make a trainable parameter as an input to the computation graph.
The error is RuntimeError: One of the differentiated Variables appears to not have been used in the graph