Skip to main content

CrossEntropyLoss

CrossEntropyLoss(weight=None, ignore_index=None, reduction="mean")

Cross entropy over class logits with the class axis last: the log-softmax followed by the negative log-likelihood.

The module form of clika_runtime.nn.functional.cross_entropy: construct it once with the settings, then call it like a function.

Args: weight: a per-class weight [C]; unset weighs every class 1; None takes the function's own default. ignore_index: a target value whose positions contribute no loss; unset masks nothing; None takes the function's own default. reduction: how the per-position losses reduce.

__init__​

__init__(self, weight: 'Tensor | None' = None, ignore_index: 'int | None' = None, reduction: '_Reduction' = 'mean') -> 'None'

Initialize self. See help(type(self)) for accurate signature.

extra_repr​

extra_repr(self) -> 'str'

extra_repr() -> str

One line of per-class detail for :meth:__repr__; a layer prints its geometry here (in_features=64, out_features=256).

forward​

forward(self, input: 'Tensor', target: 'Tensor') -> 'Tensor'

forward(input, target) -> Tensor

Runs clika_runtime.nn.functional.cross_entropy on input, target with the stored settings; returns a new tensor.