Skip to content
fn

hardtanh_

→Tensor
hardtanh_(input: Tensor, min_val: float = -1.0, max_val: float = 1.0, inplace: bool = True)

In-place hardtanh — clamps input to [min_val, max_val] in place.

Parameters

inputTensor
Input; modified in place.
min_valfloat= -1.0
Lower clamp bound. Default -1.0.
max_valfloat= 1.0
Upper clamp bound. Default 1.0.
inplacebool= True
False returns hardtanh's fresh result instead. Default True.

Returns

Tensor

The same input tensor, now clamped.

Used by 1