log_loss

paddle.nn.functional. log_loss ( input, label, epsilon=0.0001, name=None ) [source]

Negative Log Loss Layer

This layer accepts input predictions and target label and returns the negative log loss.

\[Out = -label * \log{(input + \epsilon)} - (1 - label) * \log{(1 - input + \epsilon)}\]
Parameters
  • input (Tensor|list) – A 2-D tensor with shape [N x 1], where N is the batch size. This input is a probability computed by the previous operator. Data type float32.

  • label (Tensor|list) – The ground truth which is a 2-D tensor with shape [N x 1], where N is the batch size. Data type float32.

  • epsilon (float, optional) – A small number for numerical stability. Default 1e-4.

  • name (str|None) – For detailed information, please refer to Name . Usually name is no need to set and None by default.

Returns

Tensor, which shape is [N x 1], data type is float32.

Examples

>>> import paddle
>>> import paddle.nn.functional as F

>>> label = paddle.randn((10,1))
>>> prob = paddle.randn((10,1))
>>> cost = F.log_loss(input=prob, label=label)