ncdl.nn.Threshold
- class ncdl.nn.Threshold(*args: Any, **kwargs: Any)
Thresholds each element of the input Lattice Tensor.
Threshold is defined as:
\[\begin{split}y = \begin{cases} x, &\text{ if } x > \text{threshold} \\ \text{value}, &\text{ otherwise } \end{cases}\end{split}\]- Parameters:
threshold – The value to threshold at
value – The value to replace with
inplace – can optionally do the operation in-place. Default:
False
- Shape:
Input: \((*)\), where \(*\) means any number of dimensions.
Output: \((*)\), same shape as the input.
Examples:
>>> m = nn.Threshold(0.1, 20) >>> input = torch.randn(2) >>> output = m(input)
- __init__(threshold: float, value: float, inplace: bool = False) None
Methods
__init__(threshold, value[, inplace])extra_repr()forward(input)Attributes
thresholdvalueinplace