Return the element of vector that is closest to scalar in absolute difference. If there is a tie, return the first such element in vector.
vector
scalar
Input
vector = tensor([10., 7., 2.]) scalar = 8.0
Output
tensor(7.)
This one's part of Premium. Unlock the full PyTorch track plus every other premium problem on the site.
solve(...)