Hi,
Pytorch is not really built to do univariate optimization.
But your approach looks like the right was to do this.
Note that Variable
is not needed anymore and you can simply do mean = torch.ones(1, 1, requires_grad=True)
.
And replace print(mean.data)
by print(mean)
or print(mean.detach())
.