# Why has cross entropy become the classification standard loss function and not Kullbeck Leibler divergence?

Cross entropy is identical to the KL divergence plus entropy of target distribution. KL equals to zero when the two distributions are the same, which seems more intuitive to me than the entropy of the target distribution, which is what cross entropy is on a match.

I'm not saying there's more information in one of the other except that a human view may find a zero more intuitive than a positive. Of course, one usually uses a evaluative method to really see how well classification occurs. But is the choice of cross entropy over KL historic?

When it comes to classification problem in machine learning, the cross entropy and KL divergence are equal. As already stated in the question, the general formula is this:

$$H(p, q) = H(p) + D_{KL}(p||q)$$

Where $$p$$ a “true” distribution and $$q$$ is an estimated distribution, $$H(p, q)$$ is the cross-entropy, $$H(p)$$ is the entropy and $$D$$ is the Kullback-Leibler divergence.

Note that in machine learning, $$p$$ is a one-hot representation of the ground-truth class, i.e.,

$$p = [0,..., 1, ..., 0]$$

which is basically a delta-function distribution. But the entropy of the delta function is zero, hence KL divergence simply equals the cross-entropy.

In fact, even if $$H(p)$$ wasn't $$0$$ (e.g., soft labels), it is fixed and has no contribution to the gradient. In terms of optimization, it's safe to simply remove it and optimize the Kullback-Leibler divergence.

Cross-entropy is an entropy, not an entropy difference.

A more natural and perhaps intuitive way to conceptualize the categorization criteria is through a relation rather than a definition.

$H(P, Q) - H(P) = D_{\mathrm{KL}}(P\|Q) = - \sum_i P(i) \log\frac{Q(i)}{P(i)}$

This follows parallels, identified by Claude Shannon with John von Neumann, between quantum mechanical thermodynamics and information theory. Entropy is not an absolute quantity. It is a relative one, so neither entropy nor cross entropy can be calculated, but their difference can be for either the discrete case above or its continuous sibling below.

$H(P, Q) - H(P) = D_{\mathrm{KL}}(P\|Q) = - \int_{-\infty}^\infty \, p(x) \log\frac {q(x)} {p(x)} \, dx$

Although we may see $H(...) = ...$ in the literature, with no H'(...) on the right hand side of the equation, it is not technically accurate. In such cases there is always some implied entropy to which the entropy on the left hand side is relative.
{"ft_lang_label":"__label__en","ft_lang_prob":0.93868494,"math_prob":0.99588317,"size":544,"snap":"2019-51-2020-05","text_gpt3_token_len":107,"char_repetition_ratio":0.1388889,"word_repetition_ratio":0.0,"special_character_ratio":0.19301471,"punctuation_ratio":0.07692308,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9997867,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-12-09T15:05:43Z\",\"WARC-Record-ID\":\"<urn:uuid:2c9d82e4-97a4-4da7-bd4d-4c764b5ae719>\",\"Content-Length\":\"139004\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:d463a3ba-78b3-4845-99c3-597478880fdd>\",\"WARC-Concurrent-To\":\"<urn:uuid:d5d5bb2c-fcb8-49b7-a18e-c624c3e75c7b>\",\"WARC-IP-Address\":\"151.101.193.69\",\"WARC-Target-URI\":\"https://ai.stackexchange.com/questions/3065/why-has-cross-entropy-become-the-classification-standard-loss-function-and-not-k/4185\",\"WARC-Payload-Digest\":\"sha1:VERZMYO7NIUG6LJ4Y5TMK23NVC7Z3OWG\",\"WARC-Block-Digest\":\"sha1:BA6Y5Z34IZEP6F3QZDK3RG76ERI33AAV\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-51/CC-MAIN-2019-51_segments_1575540519149.79_warc_CC-MAIN-20191209145254-20191209173254-00185.warc.gz\"}"}