Clamp all elements in x into the range min, max and return a resulting tensor.

tch_clamp(x, min, max)

Arguments

x

tensor object

min

lower-bound of the range to be clamped to

max

upper-bound of the range to be clamped to

Examples

x <- tensor(1:10) tch_clamp(x, 5, 7)
#> tensor #> 5 #> 5 #> 5 #> 5 #> 5 #> 6 #> 7 #> 7 #> 7 #> 7 #> [ Variable[CPUIntType]{10} ]