Closed zanellar closed 1 year ago
Hi @zanellar - can you explain a bit more what you are trying to do, or perhaps provide a code example?
Most of the tools in this package concern optimizing a scalar function of multiple variables.
I need to find the root of a function from R^n to R^m
import torch
from torchmin import minimize
initial_x = torch.tensor([4.,5.], requires_grad = True)
def solve_func(x):
return torch.exp(x) - torch.tensor([2.,1.])
res = minimize(
solve_func,
initial_x,
method='bfgs',
options=dict(line_search='strong-wolfe'),
max_iter=50,
disp=2
)
print('final x: {}'.format(res.x))
Hey @zanellar, to minimize an R^n to R^m function you should try the least squares solver: https://pytorch-minimize.readthedocs.io/en/latest/api/generated/torchmin.least_squares.html#torchmin.least_squares
Closing this now that @bhalazs has pointed out the correct solution
hi, do you have implemented also the VectorFunction?