# log_loss¶

paddle.fluid.layers.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 (Variable|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 (Variable|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

A 2-D tensor with shape [N x 1], the negative log loss.

Return type

Variable

Examples

import paddle.fluid as fluid
label = fluid.data(name='label', shape=[-1, 1], dtype='int64')
prob = fluid.data(name='prob', shape=[-1, 10], dtype='float32')
cost = fluid.layers.log_loss(input=prob, label=label)