- Source: Cross-entropy
- Pengenalan iris
- Venus
- Penghargaan Nebula untuk Cerita Pendek Terbaik
- Cross-entropy
- Entropy (information theory)
- Cross-entropy method
- Kullback–Leibler divergence
- Ensemble learning
- Principle of maximum entropy
- Perplexity
- Tsallis entropy
- Cross-entropy benchmarking
- Neural machine translation
Gridman Universe (2023)
A Love Story of Assassin (2024)
In Love and Deep Water (2023)
This Gun for Hire (1942)
GTMAX (2024)
Artikel: Cross-entropy GudangMovies21 Rebahinxxi
In information theory, the cross-entropy between two probability distributions
p
{\displaystyle p}
and
q
{\displaystyle q}
, over the same underlying set of events, measures the average number of bits needed to identify an event drawn from the set when the coding scheme used for the set is optimized for an estimated probability distribution
q
{\displaystyle q}
, rather than the true distribution
p
{\displaystyle p}
.
Definition
The cross-entropy of the distribution
q
{\displaystyle q}
relative to a distribution
p
{\displaystyle p}
over a given set is defined as follows:
H
(
p
,
q
)
=
−
E
p
[
log
q
]
,
{\displaystyle H(p,q)=-\operatorname {E} _{p}[\log q],}
where
E
p
[
⋅
]
{\displaystyle E_{p}[\cdot ]}
is the expected value operator with respect to the distribution
p
{\displaystyle p}
.
The definition may be formulated using the Kullback–Leibler divergence
D
K
L
(
p
∥
q
)
{\displaystyle D_{\mathrm {KL} }(p\parallel q)}
, divergence of
p
{\displaystyle p}
from
q
{\displaystyle q}
(also known as the relative entropy of
p
{\displaystyle p}
with respect to
q
{\displaystyle q}
).
H
(
p
,
q
)
=
H
(
p
)
+
D
K
L
(
p
∥
q
)
,
{\displaystyle H(p,q)=H(p)+D_{\mathrm {KL} }(p\parallel q),}
where
H
(
p
)
{\displaystyle H(p)}
is the entropy of
p
{\displaystyle p}
.
For discrete probability distributions
p
{\displaystyle p}
and
q
{\displaystyle q}
with the same support
X
{\displaystyle {\mathcal {X}}}
, this means
The situation for continuous distributions is analogous. We have to assume that
p
{\displaystyle p}
and
q
{\displaystyle q}
are absolutely continuous with respect to some reference measure
r
{\displaystyle r}
(usually
r
{\displaystyle r}
is a Lebesgue measure on a Borel σ-algebra). Let
P
{\displaystyle P}
and
Q
{\displaystyle Q}
be probability density functions of
p
{\displaystyle p}
and
q
{\displaystyle q}
with respect to
r
{\displaystyle r}
. Then
−
∫
X
P
(
x
)
log
Q
(
x
)
d
x
=
E
p
[
−
log
Q
]
,
{\displaystyle -\int _{\mathcal {X}}P(x)\,\log Q(x)\,\mathrm {d} x=\operatorname {E} _{p}[-\log Q],}
and therefore
NB: The notation
H
(
p
,
q
)
{\displaystyle H(p,q)}
is also used for a different concept, the joint entropy of
p
{\displaystyle p}
and
q
{\displaystyle q}
.
Motivation
In information theory, the Kraft–McMillan theorem establishes that any directly decodable coding scheme for coding a message to identify one value
x
i
{\displaystyle x_{i}}
out of a set of possibilities
{
x
1
,
…
,
x
n
}
{\displaystyle \{x_{1},\ldots ,x_{n}\}}
can be seen as representing an implicit probability distribution
q
(
x
i
)
=
(
1
2
)
ℓ
i
{\displaystyle q(x_{i})=\left({\frac {1}{2}}\right)^{\ell _{i}}}
over
{
x
1
,
…
,
x
n
}
{\displaystyle \{x_{1},\ldots ,x_{n}\}}
, where
ℓ
i
{\displaystyle \ell _{i}}
is the length of the code for
x
i
{\displaystyle x_{i}}
in bits. Therefore, cross-entropy can be interpreted as the expected message-length per datum when a wrong distribution
q
{\displaystyle q}
is assumed while the data actually follows a distribution
p
{\displaystyle p}
. That is why the expectation is taken over the true probability distribution
p
{\displaystyle p}
and not
q
.
{\displaystyle q.}
Indeed the expected message-length under the true distribution
p
{\displaystyle p}
is
E
p
[
ℓ
]
=
−
E
p
[
ln
q
(
x
)
ln
(
2
)
]
{\displaystyle \operatorname {E} _{p}[\ell ]=-\operatorname {E} _{p}\left[{\frac {\ln {q(x)}}{\ln(2)}}\right]}
=
−
E
p
[
log
2
q
(
x
)
]
=
−
∑
x
i
p
(
x
i
)
log
2
q
(
x
i
)
{\displaystyle =-\operatorname {E} _{p}\left[\log _{2}{q(x)}\right]=-\sum _{x_{i}}p(x_{i})\,\log _{2}q(x_{i})}
=
−
∑
x
p
(
x
)
log
2
q
(
x
)
=
H
(
p
,
q
)
.
{\displaystyle =-\sum _{x}p(x)\,\log _{2}q(x)=H(p,q).}
Estimation
There are many situations where cross-entropy needs to be measured but the distribution of
p
{\displaystyle p}
is unknown. An example is language modeling, where a model is created based on a training set
T
{\displaystyle T}
, and then its cross-entropy is measured on a test set to assess how accurate the model is in predicting the test data. In this example,
p
{\displaystyle p}
is the true distribution of words in any corpus, and
q
{\displaystyle q}
is the distribution of words as predicted by the model. Since the true distribution is unknown, cross-entropy cannot be directly calculated. In these cases, an estimate of cross-entropy is calculated using the following formula:
H
(
T
,
q
)
=
−
∑
i
=
1
N
1
N
log
2
q
(
x
i
)
{\displaystyle H(T,q)=-\sum _{i=1}^{N}{\frac {1}{N}}\log _{2}q(x_{i})}
where
N
{\displaystyle N}
is the size of the test set, and
q
(
x
)
{\displaystyle q(x)}
is the probability of event
x
{\displaystyle x}
estimated from the training set. In other words,
q
(
x
i
)
{\displaystyle q(x_{i})}
is the probability estimate of the model that the i-th word of the text is
x
i
{\displaystyle x_{i}}
. The sum is averaged over the
N
{\displaystyle N}
words of the test. This is a Monte Carlo estimate of the true cross-entropy, where the test set is treated as samples from
p
(
x
)
{\displaystyle p(x)}
.
Relation to maximum likelihood
The cross entropy arises in classification problems when introducing a logarithm in the guise of the log-likelihood function.
The section is concerned with the subject of estimation of the probability of different possible discrete outcomes. To this end, denote a parametrized family of distributions by
q
θ
{\displaystyle q_{\theta }}
, with
θ
{\displaystyle \theta }
subject to the optimization effort. Consider a given finite sequence of
N
{\displaystyle N}
values
x
i
{\displaystyle x_{i}}
from a training set, obtained from conditionally independent sampling. The likelihood assigned to any considered parameter
θ
{\displaystyle \theta }
of the model is then given by the product over all probabilities
q
θ
(
X
=
x
i
)
{\displaystyle q_{\theta }(X=x_{i})}
.
Repeated occurrences are possible, leading to equal factors in the product. If the count of occurrences of the value equal to
x
i
{\displaystyle x_{i}}
(for some index
i
{\displaystyle i}
) is denoted by
#
x
i
{\displaystyle \#x_{i}}
, then the frequency of that value equals
#
x
i
/
N
{\displaystyle \#x_{i}/N}
. Denote the latter by
p
(
X
=
x
i
)
{\displaystyle p(X=x_{i})}
, as it may be understood as empirical approximation to the probability distribution underlying the scenario. Further denote by
P
P
:=
e
H
(
p
,
q
θ
)
{\displaystyle PP:={\mathrm {e} }^{H(p,q_{\theta })}}
the perplexity, which can be seen to equal
∏
x
i
q
θ
(
X
=
x
i
)
−
p
(
X
=
x
i
)
{\textstyle \prod _{x_{i}}q_{\theta }(X=x_{i})^{-p(X=x_{i})}}
by the calculation rules for the logarithm, and where the product is over the values without double counting. So
L
(
θ
;
x
)
=
∏
i
q
θ
(
X
=
x
i
)
=
∏
x
i
q
θ
(
X
=
x
i
)
#
x
i
=
P
P
−
N
=
e
−
N
⋅
H
(
p
,
q
θ
)
{\displaystyle {\mathcal {L}}(\theta ;{\mathbf {x} })=\prod _{i}q_{\theta }(X=x_{i})=\prod _{x_{i}}q_{\theta }(X=x_{i})^{\#x_{i}}=PP^{-N}={\mathrm {e} }^{-N\cdot H(p,q_{\theta })}}
or
log
L
(
θ
;
x
)
=
−
N
⋅
H
(
p
,
q
θ
)
.
{\displaystyle \log {\mathcal {L}}(\theta ;{\mathbf {x} })=-N\cdot H(p,q_{\theta }).}
Since the logarithm is a monotonically increasing function, it does not affect extremization. So observe that the likelihood maximization amounts to minimization of the cross-entropy.
Cross-entropy minimization
Cross-entropy minimization is frequently used in optimization and rare-event probability estimation. When comparing a distribution
q
{\displaystyle q}
against a fixed reference distribution
p
{\displaystyle p}
, cross-entropy and KL divergence are identical up to an additive constant (since
p
{\displaystyle p}
is fixed): According to the Gibbs' inequality, both take on their minimal values when
p
=
q
{\displaystyle p=q}
, which is
0
{\displaystyle 0}
for KL divergence, and
H
(
p
)
{\displaystyle \mathrm {H} (p)}
for cross-entropy. In the engineering literature, the principle of minimizing KL divergence (Kullback's "Principle of Minimum Discrimination Information") is often called the Principle of Minimum Cross-Entropy (MCE), or Minxent.
However, as discussed in the article Kullback–Leibler divergence, sometimes the distribution
q
{\displaystyle q}
is the fixed prior reference distribution, and the distribution
p
{\displaystyle p}
is optimized to be as close to
q
{\displaystyle q}
as possible, subject to some constraint. In this case the two minimizations are not equivalent. This has led to some ambiguity in the literature, with some authors attempting to resolve the inconsistency by restating cross-entropy to be
D
K
L
(
p
∥
q
)
{\displaystyle D_{\mathrm {KL} }(p\parallel q)}
, rather than
H
(
p
,
q
)
{\displaystyle H(p,q)}
. In fact, cross-entropy is another name for relative entropy; see Cover and Thomas and Good. On the other hand,
H
(
p
,
q
)
{\displaystyle H(p,q)}
does not agree with the literature and can be misleading.
Cross-entropy loss function and logistic regression
Cross-entropy can be used to define a loss function in machine learning and optimization. Mao, Mohri, and Zhong (2023) give an extensive analysis of the properties of the family of cross-entropy loss functions in machine learning, including theoretical learning guarantees and extensions to adversarial learning. The true probability
p
i
{\displaystyle p_{i}}
is the true label, and the given distribution
q
i
{\displaystyle q_{i}}
is the predicted value of the current model. This is also known as the log loss (or logarithmic loss or logistic loss); the terms "log loss" and "cross-entropy loss" are used interchangeably.
More specifically, consider a binary regression model which can be used to classify observations into two possible classes (often simply labelled
0
{\displaystyle 0}
and
1
{\displaystyle 1}
). The output of the model for a given observation, given a vector of input features
x
{\displaystyle x}
, can be interpreted as a probability, which serves as the basis for classifying the observation. In logistic regression, the probability is modeled using the logistic function
g
(
z
)
=
1
/
(
1
+
e
−
z
)
{\displaystyle g(z)=1/(1+e^{-z})}
where
z
{\displaystyle z}
is some function of the input vector
x
{\displaystyle x}
, commonly just a linear function. The probability of the output
y
=
1
{\displaystyle y=1}
is given by
q
y
=
1
=
y
^
≡
g
(
w
⋅
x
)
=
1
1
+
e
−
w
⋅
x
,
{\displaystyle q_{y=1}={\hat {y}}\equiv g(\mathbf {w} \cdot \mathbf {x} )={\frac {1}{1+e^{-\mathbf {w} \cdot \mathbf {x} }}},}
where the vector of weights
w
{\displaystyle \mathbf {w} }
is optimized through some appropriate algorithm such as gradient descent. Similarly, the complementary probability of finding the output
y
=
0
{\displaystyle y=0}
is simply given by
q
y
=
0
=
1
−
y
^
.
{\displaystyle q_{y=0}=1-{\hat {y}}.}
Having set up our notation,
p
∈
{
y
,
1
−
y
}
{\displaystyle p\in \{y,1-y\}}
and
q
∈
{
y
^
,
1
−
y
^
}
{\displaystyle q\in \{{\hat {y}},1-{\hat {y}}\}}
, we can use cross-entropy to get a measure of dissimilarity between
p
{\displaystyle p}
and
q
{\displaystyle q}
:
H
(
p
,
q
)
=
−
∑
i
p
i
log
q
i
=
−
y
log
y
^
−
(
1
−
y
)
log
(
1
−
y
^
)
.
{\displaystyle H(p,q)\ =\ -\sum _{i}p_{i}\log q_{i}\ =\ -y\log {\hat {y}}-(1-y)\log(1-{\hat {y}}).}
Logistic regression typically optimizes the log loss for all the observations on which it is trained, which is the same as optimizing the average cross-entropy in the sample. Other loss functions that penalize errors differently can be also used for training, resulting in models with different final test accuracy. For example, suppose we have
N
{\displaystyle N}
samples with each sample indexed by
n
=
1
,
…
,
N
{\displaystyle n=1,\dots ,N}
. The average of the loss function is then given by:
J
(
w
)
=
1
N
∑
n
=
1
N
H
(
p
n
,
q
n
)
=
−
1
N
∑
n
=
1
N
[
y
n
log
y
^
n
+
(
1
−
y
n
)
log
(
1
−
y
^
n
)
]
,
{\displaystyle J(\mathbf {w} )\ =\ {\frac {1}{N}}\sum _{n=1}^{N}H(p_{n},q_{n})\ =\ -{\frac {1}{N}}\sum _{n=1}^{N}\ {\bigg [}y_{n}\log {\hat {y}}_{n}+(1-y_{n})\log(1-{\hat {y}}_{n}){\bigg ]}\,,}
where
y
^
n
≡
g
(
w
⋅
x
n
)
=
1
/
(
1
+
e
−
w
⋅
x
n
)
{\displaystyle {\hat {y}}_{n}\equiv g(\mathbf {w} \cdot \mathbf {x} _{n})=1/(1+e^{-\mathbf {w} \cdot \mathbf {x} _{n}})}
, with
g
(
z
)
{\displaystyle g(z)}
the logistic function as before.
The logistic loss is sometimes called cross-entropy loss. It is also known as log loss. (In this case, the binary label is often denoted by {−1,+1}.)
Remark: The gradient of the cross-entropy loss for logistic regression is the same as the gradient of the squared-error loss for linear regression. That is, define
X
T
=
(
1
x
11
…
x
1
p
1
x
21
⋯
x
2
p
⋮
⋮
⋮
1
x
n
1
⋯
x
n
p
)
∈
R
n
×
(
p
+
1
)
,
{\displaystyle X^{\mathsf {T}}={\begin{pmatrix}1&x_{11}&\dots &x_{1p}\\1&x_{21}&\cdots &x_{2p}\\\vdots &\vdots &&\vdots \\1&x_{n1}&\cdots &x_{np}\\\end{pmatrix}}\in \mathbb {R} ^{n\times (p+1)},}
y
i
^
=
f
^
(
x
i
1
,
…
,
x
i
p
)
=
1
1
+
exp
(
−
β
0
−
β
1
x
i
1
−
⋯
−
β
p
x
i
p
)
,
{\displaystyle {\hat {y_{i}}}={\hat {f}}(x_{i1},\dots ,x_{ip})={\frac {1}{1+\exp(-\beta _{0}-\beta _{1}x_{i1}-\dots -\beta _{p}x_{ip})}},}
L
(
β
)
=
−
∑
i
=
1
N
[
y
i
log
y
^
i
+
(
1
−
y
i
)
log
(
1
−
y
^
i
)
]
.
{\displaystyle L({\boldsymbol {\beta }})=-\sum _{i=1}^{N}\left[y_{i}\log {\hat {y}}_{i}+(1-y_{i})\log(1-{\hat {y}}_{i})\right].}
Then we have the result
∂
∂
β
L
(
β
)
=
X
T
(
Y
^
−
Y
)
.
{\displaystyle {\frac {\partial }{\partial {\boldsymbol {\beta }}}}L({\boldsymbol {\beta }})=X^{T}({\hat {Y}}-Y).}
The proof is as follows. For any
y
^
i
{\displaystyle {\hat {y}}_{i}}
, we have
∂
∂
β
0
ln
1
1
+
e
−
β
0
+
k
0
=
e
−
β
0
+
k
0
1
+
e
−
β
0
+
k
0
,
{\displaystyle {\frac {\partial }{\partial \beta _{0}}}\ln {\frac {1}{1+e^{-\beta _{0}+k_{0}}}}={\frac {e^{-\beta _{0}+k_{0}}}{1+e^{-\beta _{0}+k_{0}}}},}
∂
∂
β
0
ln
(
1
−
1
1
+
e
−
β
0
+
k
0
)
=
−
1
1
+
e
−
β
0
+
k
0
,
{\displaystyle {\frac {\partial }{\partial \beta _{0}}}\ln \left(1-{\frac {1}{1+e^{-\beta _{0}+k_{0}}}}\right)={\frac {-1}{1+e^{-\beta _{0}+k_{0}}}},}
∂
∂
β
0
L
(
β
)
=
−
∑
i
=
1
N
[
y
i
⋅
e
−
β
0
+
k
0
1
+
e
−
β
0
+
k
0
−
(
1
−
y
i
)
1
1
+
e
−
β
0
+
k
0
]
=
−
∑
i
=
1
N
[
y
i
−
y
^
i
]
=
∑
i
=
1
N
(
y
^
i
−
y
i
)
,
{\displaystyle {\begin{aligned}{\frac {\partial }{\partial \beta _{0}}}L({\boldsymbol {\beta }})&=-\sum _{i=1}^{N}\left[{\frac {y_{i}\cdot e^{-\beta _{0}+k_{0}}}{1+e^{-\beta _{0}+k_{0}}}}-(1-y_{i}){\frac {1}{1+e^{-\beta _{0}+k_{0}}}}\right]\\&=-\sum _{i=1}^{N}\left[y_{i}-{\hat {y}}_{i}\right]=\sum _{i=1}^{N}({\hat {y}}_{i}-y_{i}),\end{aligned}}}
∂
∂
β
1
ln
1
1
+
e
−
β
1
x
i
1
+
k
1
=
x
i
1
e
k
1
e
β
1
x
i
1
+
e
k
1
,
{\displaystyle {\frac {\partial }{\partial \beta _{1}}}\ln {\frac {1}{1+e^{-\beta _{1}x_{i1}+k_{1}}}}={\frac {x_{i1}e^{k_{1}}}{e^{\beta _{1}x_{i1}}+e^{k_{1}}}},}
∂
∂
β
1
ln
[
1
−
1
1
+
e
−
β
1
x
i
1
+
k
1
]
=
−
x
i
1
e
β
1
x
i
1
e
β
1
x
i
1
+
e
k
1
,
{\displaystyle {\frac {\partial }{\partial \beta _{1}}}\ln \left[1-{\frac {1}{1+e^{-\beta _{1}x_{i1}+k_{1}}}}\right]={\frac {-x_{i1}e^{\beta _{1}x_{i1}}}{e^{\beta _{1}x_{i1}}+e^{k_{1}}}},}
∂
∂
β
1
L
(
β
)
=
−
∑
i
=
1
N
x
i
1
(
y
i
−
y
^
i
)
=
∑
i
=
1
N
x
i
1
(
y
^
i
−
y
i
)
.
{\displaystyle {\frac {\partial }{\partial \beta _{1}}}L({\boldsymbol {\beta }})=-\sum _{i=1}^{N}x_{i1}(y_{i}-{\hat {y}}_{i})=\sum _{i=1}^{N}x_{i1}({\hat {y}}_{i}-y_{i}).}
In a similar way, we eventually obtain the desired result.
Amended cross-entropy
It may be beneficial to train an ensemble of models that have diversity, such that when they are combined, their predictive accuracy is augmented.
Assuming a simple ensemble of
K
{\displaystyle K}
classifiers is assembled via averaging the outputs, then the amended cross-entropy is given by
e
k
=
H
(
p
,
q
k
)
−
λ
K
∑
j
≠
k
H
(
q
j
,
q
k
)
{\displaystyle e^{k}=H(p,q^{k})-{\frac {\lambda }{K}}\sum _{j\neq k}H(q^{j},q^{k})}
where
e
k
{\displaystyle e^{k}}
is the cost function of the
k
t
h
{\displaystyle k^{th}}
classifier,
q
k
{\displaystyle q^{k}}
is the output probability of the
k
t
h
{\displaystyle k^{th}}
classifier,
p
{\displaystyle p}
is the true probability to be estimated, and
λ
{\displaystyle \lambda }
is a parameter between 0 and 1 that defines the 'diversity' that we would like to establish among the ensemble. When
λ
=
0
{\displaystyle \lambda =0}
we want each classifier to do its best regardless of the ensemble and when
λ
=
1
{\displaystyle \lambda =1}
we would like the classifier to be as diverse as possible.
See also
Cross-entropy method
Logistic regression
Conditional entropy
Kullback–Leibler distance
Maximum-likelihood estimation
Mutual information
Perplexity
References
Further reading
de Boer, Kroese, D.P., Mannor, S. and Rubinstein, R.Y. (2005). A tutorial on the cross-entropy method. Annals of Operations Research 134 (1), 19–67.
Kata Kunci Pencarian:
Artikel Terkait "cross entropy"
machine learning - What is cross-entropy? - Stack Overflow
Correct, cross-entropy describes the loss between two probability distributions. It is one of many possible loss functions. Then we can use, for example, gradient descent algorithm to find the minimum. Yes, the cross-entropy loss function can be used as part of gradient descent. Further reading: one of my other answers related to TensorFlow.
python - `CrossEntropyLoss()` in PyTorch - Stack Overflow
The combination of nn.LogSoftmax and nn.NLLLoss is equivalent to using nn.CrossEntropyLoss.This terminology is a particularity of PyTorch, as the nn.NLLoss [sic] computes, in fact, the cross entropy but with log probability predictions as inputs where nn.CrossEntropyLoss takes scores (sometimes called logits).
Trying to understand cross_entropy loss in PyTorch
23 Jul 2019 · This is a very newbie question but I'm trying to wrap my head around cross_entropy loss in Torch so I created the following code: x = torch.FloatTensor([ [1.,0.,0.] ...
How to handle log (0) when using cross entropy - Stack Overflow
25 Apr 2018 · loss = np.multiply(np.log(predY), Y) + np.multiply((1 - Y), np.log(1 - predY)) #cross entropy cost = -np.sum(loss)/m #num of examples in batch is m Probability of Y. predY is computed using sigmoid and logits can be thought as the outcome of from a neural network before reaching the classification step
What is the problem with my implementation of the cross-entropy …
19 Nov 2017 · According to the above description, I wrote down the codes by clipping the predictions to [epsilon, 1 − epsilon] range, then computing the cross_entropy based on the above formula: def cross_entropy(predictions, targets, epsilon=1e-12): """ Computes cross entropy between targets (encoded as one-hot vectors) and predictions.
Unbalanced data and weighted cross entropy - Stack Overflow
15 Jun 2017 · Note that weighted_cross_entropy_with_logits is the weighted variant of sigmoid_cross_entropy_with_logits. Sigmoid cross entropy is typically used for binary classification. Yes, it can handle multiple labels, but sigmoid cross entropy basically makes a (binary) decision on each of them -- for example, for a face recognition net, those (not ...
python - UNET with CrossEntropy Loss Function - Stack Overflow
29 Apr 2021 · Now I send my images to the model and the dimension of the predicted masks are [2,128,128]. Now to train a model I choose 16 as batch size. So, now I have input as [16,3,128,128] so the predicted dimension is [16,2,128,128]. But I have ground-truth masks as [16,1,128,128]. Now how can I apply Cross entropy loss in Pytorch?
Comparing MSE loss and cross-entropy loss in terms of …
16 Mar 2018 · , this is called binary cross entropy. Categorical cross entropy. Generalization of the cross entropy follows the general case when the random variable is multi-variant(is from Multinomial distribution ) with the following probability distribution. Taking negative natural logarithm of both sides yields categorical cross entropy loss.,
Pytorch LSTM: Target Dimension in Calculating Cross Entropy Loss
24 Nov 2018 · The examples I was following seemed to be doing the same thing, but it was different on the Pytorch docs on cross entropy loss. The docs say the target should be of dimension (N), where each value is 0 ≤ targets[i] ≤ C−1 and C is the number of classes.
classification - Difference between CrossEntropyLoss and …
11 Jan 2021 · Both the cross-entropy and log-likelihood are two different interpretations of the same formula. In the log-likelihood case, we maximize the probability (actually likelihood) of the correct class which is the same as minimizing cross-entropy.