pytorch / 2 / generated / torch.ao.nn.quantized.relu6.html

ReLU6

class torch.ao.nn.quantized.ReLU6(inplace=False) [source]

Applies the element-wise function:

ReLU6 ( x ) = min ( max ( x 0 , x ) , q ( 6 ) ) \text{ReLU6}(x) = \min(\max(x_0, x), q(6)) , where x 0 x_0 is the zero_point, and q ( 6 ) q(6) is the quantized representation of number 6.

Parameters

inplace (bool) – can optionally do the operation in-place. Default: False

Shape:
  • Input: ( N , ) (N, *) where * means, any number of additional dimensions
  • Output: ( N , ) (N, *) , same shape as the input
../_images/ReLU6.png

Examples:

>>> m = nn.quantized.ReLU6()
>>> input = torch.randn(2)
>>> input = torch.quantize_per_tensor(input, 1.0, 0, dtype=torch.qint32)
>>> output = m(input)

© 2024, PyTorch Contributors
PyTorch has a BSD-style license, as found in the LICENSE file.
https://pytorch.org/docs/2.1/generated/torch.ao.nn.quantized.ReLU6.html