Min
(Tensor) the input tensor.
(int) the dimension to reduce.
(bool) whether the output tensor has dim
retained or not.
(tuple, optional) the tuple of two output tensors (min, min_indices)
(Tensor) the second input tensor
Returns the minimum value of all elements in the input
tensor.
Returns a namedtuple (values, indices)
where values
is the minimum
value of each row of the input
tensor in the given dimension
dim
. And indices
is the index location of each minimum value found
(argmin).
indices
does not necessarily contain the first occurrence of each
minimal value found, unless it is unique.
The exact implementation details are device-specific.
Do not expect the same result when run on CPU and GPU in general.
If keepdim
is TRUE
, the output tensors are of the same size as
input
except in the dimension dim
where they are of size 1.
Otherwise, dim
is squeezed (see torch_squeeze
), resulting in
the output tensors having 1 fewer dimension than input
.
Each element of the tensor input
is compared with the corresponding
element of the tensor other
and an element-wise minimum is taken.
The resulting tensor is returned.
The shapes of input
and other
don't need to match,
but they must be broadcastable .
if (torch_is_installed()) {
a = torch_randn(c(1, 3))
a
torch_min(a)
a = torch_randn(c(4, 4))
a
torch_min(a, dim = 1)
a = torch_randn(c(4))
a
b = torch_randn(c(4))
b
torch_min(a, other = b)
}
Run the code above in your browser using DataLab