binary_search
- torchdr.binary_search(f, n, begin=None, end=None, max_iter=1000, tol=1e-09, verbose=False, dtype=torch.float64)[source]
Implement the binary search root finding method.
Perform a batched binary search to find the root of an increasing function f. The domain of f is restricted to positive floats.
- Parameters:
f (function \(\mathbb{R}_{>0} \to \mathbb{R}\)) – batched 1d increasing function which root should be computed.
n (int) – size of the input of f.
begin (float or torch.Tensor of shape (n), optional) – initial lower bound of the root.
end (float or torch.Tensor of shape (n), optional) – initial upper bound of the root.
max_iter (int, optional) – maximum iterations of search.
tol (float, optional) – precision threshold at which the algorithm stops.
verbose (bool, optional) – if True, prints current bounds.
dtype (torch.dtype, optional) – data type of the input.
- Returns:
m – root of f.
- Return type:
torch.Tensor of shape (n)