---
title: "crossEntropy"
sidebar_label: "crossEntropy"
description: "Kotlin binding reference: crossEntropy."
---

<!-- Generated by tools/api_reference/generate_api_docs.py. Do not edit. -->

//[clika-runtime](../../../index.md)/[io.clika.runtime](../index.md)/[Ops](index.md)/[crossEntropy](crossEntropy.md)

# crossEntropy

[common]\
fun [crossEntropy](crossEntropy.md)(input: [Tensor](../Tensor/index.md), target: [Tensor](../Tensor/index.md), weight: [Tensor](../Tensor/index.md)? = null, ignoreIndex: [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)? = null, reduction: [Reduction](../Reduction/index.md) = Reduction.MEAN): [Tensor](../Tensor/index.md)

`crossEntropy(input: Tensor, target: Tensor, weight: Tensor? = null, ignoreIndex: Long? = null, reduction: Reduction = Reduction.MEAN)`: the `cross_entropy` operator. Cross-entropy loss over class LOGITS; the class dim is LAST. Equivalent to `log_softmax` over the class axis followed by negative-log-likelihood: