Skip to content
fn

nll_loss_op

→TensorImplPtr
int nll_loss_op(const int & input, const int & target, const int & weight_or_null, int reduction, int ignore_index)

Python wrappers

Public Python APIs implemented by this engine symbol.

Public negative log-likelihood entry point.

Parameters

inputTensorImplPtr
Log-probabilities of shape (N, C) or (N, C, d_1, ...).
targetTensorImplPtr
Integer class labels.
weight_or_nullTensorImplPtr
Optional per-class weight vector of length CC; pass null when unused.
reductionint
0 (None), 1 (Mean), or 2 (Sum).
ignore_indexint
Class index excluded from the loss / gradient.

Returns

TensorImplPtr

Reduced or per-sample loss tensor.