poisson_nll_loss¶
- paddle.nn.functional. poisson_nll_loss ( input, label, log_input=True, full=False, epsilon=1e-08, reduction='mean', name=None ) [source]
-
Poisson negative log likelihood loss. See more detail in PoissonNLLLoss .
- Parameters
-
input (Tensor) – Input tensor, expectation of underlying Poisson distribution. The shape of input tensor should be (N, *) or (*) where (*) denotes any number of extra dimensions. It’s data type should be float16, bfloat16, float32, float64.
label (Tensor) – Label tensor, random sampled from Poisson distribution \(label \sim \text{Poisson}(input)\). The shape of input tensor should be (N, *) or (*), same shape as the input tensor. It’s data type should be float16, bfloat16, float32, float64.
log_input (bool, optional) – Whether to the treat input tensor as log input. If
Truethe loss is computed as, \(\exp(\text{input}) - \text{label} * \text{input}\) . IfFalsethen loss is \(\text{input} - \text{label} * \log(\text{input}+\text{epsilon})\) . Default:True.full (bool, optional) – Whether to compute full loss. If
True, the Stirling approximation term is added. IfFalse, the Stirling approximation is dropped. Default:False.epsilon (float, optional) – A small value to avoid evaluation of \(\log(0)\) when log_input=
False.epsilon > 0. Default: 1e-8.reduction (str, optional) – Indicate how to reduce the loss, the candicates are
'none'|'mean'|'sum'. If reduction is'mean', the reduced mean loss is returned; if reduction is'sum', the reduced sum loss is returned; if reduction is'none', no reduction will be apllied. Default is'mean'.name (str, optional) – Name for the operation (optional, default is None). For more information, please refer to Name.
Examples
import paddle import paddle.nn.functional as F input = paddle.randn([5, 2], dtype=paddle.float32) label = paddle.randn([5, 2], dtype=paddle.float32) loss = F.poisson_nll_loss(input, label, log_input=True, reduction='none') print(loss) loss = F.poisson_nll_loss(input, label, reduction='mean') print(loss)
