nll_loss¶
dragon.losses.
nll_loss
(
inputs,
axis=- 1,
ignore_index=None,
reduction='valid',
**kwargs
)[source]¶Compute the loss of negative likelihood.
Examples:
x = dragon.constant([[0.5, 0.5], [0.3, 0.7]]) x = dragon.math.log(x) y = dragon.constant([1, 0]) print(dragon.losses.nll_loss([x, y])) # 0.9485599
- Parameters:
- inputs (Sequence[dragon.Tensor]) – The tensor
input
andtarget
. - axis (int, optional, default=-1) – The reduction axis.
- ignore_index (int, optional) – The ignored value of target.
- reduction ({'none', 'sum', 'mean', 'valid'}, optional) – The reduction method.
- inputs (Sequence[dragon.Tensor]) – The tensor
- Returns:
dragon.Tensor – The output tensor.