
Last chance! 50% off unlimited learning
Sale ends in
Clamp
torch_clamp(self, min = NULL, max = NULL)
(Tensor) the input tensor.
(Number) lower-bound of the range to be clamped to
(Number) upper-bound of the range to be clamped to
Clamp all elements in input
into the range [
min
, max
]
and return
a resulting tensor:
input
is of type FloatTensor
or DoubleTensor
, args min
and max
must be real numbers, otherwise they should be integers.
Clamps all elements in input
to be larger or equal min
.
If input
is of type FloatTensor
or DoubleTensor
, value
should be a real number, otherwise it should be an integer.
Clamps all elements in input
to be smaller or equal max
.
If input
is of type FloatTensor
or DoubleTensor
, value
should be a real number, otherwise it should be an integer.
if (torch_is_installed()) {
a = torch_randn(c(4))
a
torch_clamp(a, min=-0.5, max=0.5)
a = torch_randn(c(4))
a
torch_clamp(a, min=0.5)
a = torch_randn(c(4))
a
torch_clamp(a, max=0.5)
}
Run the code above in your browser using DataLab