Rate this Page

Hardtanh#

class torch.nn.modules.activation.Hardtanh(min_val=-1.0, max_val=1.0, inplace=False, min_value=None, max_value=None)[source]#

Applies the HardTanh function element-wise.

HardTanh is defined as:

HardTanh(x)=max_valmin_valx if x> max_val  if x< min_val  otherwise 
Parameters
  • min_val (float) – minimum value of the linear region range. Default: -1

  • max_val (float) – maximum value of the linear region range. Default: 1

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

Keyword arguments min_value and max_value have been deprecated in favor of min_val and max_val.

Shape:
  • Input: (), where means any number of dimensions.

  • Output: (), same shape as the input.

../_images/Hardtanh.png

Examples:

>>> m = nn.Hardtanh(-2, 2)
>>> input = torch.randn(2)
>>> output = m(input)
extra_repr()[source]#

Return the extra representation of the module.

Return type

str

forward(input)[source]#

Runs the forward pass.

Return type

Tensor

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources
Morty Proxy This is a proxified and sanitized view of the page, visit original site.