About MSE, CEE and MLE.
1. MSE(Mean-Squared Error)
We can contact MSE loss function easily If we do AI modeling at first.
Actually, loss functions like MSE, RMSE is used in Linear Regression task now.
MSE stands for “Mean-Squared Error” and has the following formula:

If the number of data is 1 ($n=1$
), the previous average value process disappears and only $(Y_i — \hat{Y}_i)²$
remains.
So, if the loss value is 0.25 during GAN learning, $(1–0.5)²$ or $(0–0.5)²$
is the most ideal value. (1=True, 0=False)
Expressing this as a python function is as follows (assuming the number of data is 1) → n = 1
→ def MSE
2. CEE(Cross-Entropy Error)
Let’s look at CEE loss function following MSE.
CEE stands for “Cross-Entropy Error”. Also known as CELoss.
before we look at CELoss, we need to look at the concept of Entropy.
2–1. Entropy
“Entropy” is a mathematical idea that describes Uncertainty.
To explain in a bit more detail, It is a numerical expression of the certainty or amount of information that a probability distribution has.
If say we flip a coin, the probability of getting head is 100% or the probability of getting tail is 100%.
In this case, Uncertainty(=Entropy) will be “0”.
Because we can look forward
Because whatever comes out, we can predict with 100% probability.
The formula is:

Entropy is the sum of all possible outcomes.
The case of CE Loss above can be used in the case of multi-class.
As we looked at Entropy earlier, the above requires a probability value.
That’s why Softmax function is used in the last layer of NN.
The formula below(Softmax, $\sigma$
) is simply the current value divided by the total sum of the input values.

If in the case of a single-class that distinguishes only True/False, use BCELoss. (Binary Cross-Entropy Loss)
BCELoss has the following formula:

Expressing this as a python function is as follows. (assuming the number of data is 1) → n = 1
→ def CEE
Now, using the MSE and Binary CEE above, We can plot a loss value.

Through the graph above, we can know this:
1. MSE is the graph of a linear function that decreases linearly with respect to the loss value.
2. Binary CEE shows a higher value when the loss value is larger.
The reason why we use the cross entropy function when do deep learning is because, in the general case as above, when the loss value is large, a larger value is updated.
2–2. Ideal Value in GAN
We said that “0.69” is ideal loss value when we do GAN training.
The reason is following.
- GAN training updates a value via Binary CE Loss.
- Its value is 1.0 for True and 0.0 for False
- The most unstable scale is 0.5 at 1.0 and 0.0.
- A Cross Entropy for
$x=0.5, y=1.0$
is$-1.0 \times ln(0.5) — (0.0 \times ln(1–0.5)) = 0.693$
.
As this reasons, a loss value of 0.693 is the most ideal value if Discriminator and Generator are balanced during GAN training.
3. MLE(Maximum Likelihood Estimation)
MLE stands for “Maximum Likelihood Estimation”
This has to do with a distribution of dataset(=a probability distribution that this data came out) that we always talk about in GAN.
3–0. Basic
For example, There is a
예를 들어서, “구름이 흐릴 때 비가 올 확률이 얼마나 될까?” 라는 가정이 있습니다.
여기서 구름이 흐릴 때 를 확률 변수 $x$ 라고 하고, 비가 올 확률은 이 $x$ 에 대응하는 $y$ 값이 될 것입니다.
확률 변수 $x$는 2종류가 있습니다:
- 이산 확률 변수 : 주사위 눈 처럼 연속하지 않은, 이산 상태의(discrete) 값들입니다.
- 연속 확률 변수 : 셀 수 없는(uncountable) 값으로, 어떠한 상태가 아닌 영역으로 표시할 수 있는 값입니다.
3–1. 확률 분포
확률 분포는 영어로 Probability Distribution 입니다.
이는 미지수 $x$ 에 대응하는 $y$ 의 분포입니다. 우리가 normal distribution(=Gaussian distribution, 연속확률분포 중 1개), 즉 정규 분포를 표현하기 위해서 평균(mu, $\mu$), 표준편차(sigma, $\sigma$) 를 제공하고 $x$ 값을 넣게 되면 어느 $y$ 값이 나오는지 알 수 있습니다.
즉, 다시 말해서, 평균과 표준편차에 따라서 달라지는 Probability Distribution이기 때문에 $x$ 값에 따라 결과값 $y$ 가 결정되는 것입니다.
💡 참고
\mu=0, \sigma=1 일 때를
Standard Normal Distribution, 표준 정규 분포
라고 합니다.

여기서 $\mu$, $\sigma$ 를 모수, 즉 아래에서 얘기할 $\theta$ 라고 볼 수 있습니다.
모수란 모집단의 parameter, 이는 모평균과 모분산(분산 = 표준편차 $\sigma$의 제곱의 합)으로 이루어져 있습니다.
💡 참고
1. 분산에 제곱근을 씌우면 표준편차가 됩니다.
2. 표준편차는 평균으로부터 원래 데이터에 대한 오차 범위의 근사값입니다.
이를 수식으로 표현하면 다음과 같습니다
→ $f(x;\theta) = f(x;\mu, \sigma²) = N \sim X(\mu, \sigma²)$
또한, 정규 분포의 식은 다음과 같습니다.

3–2. MLE
하지만 MLE는 반대입니다. MLE는 추정문제로써, 이미 $x$ 값들은 주어지고 모수(theta = $\theta$)는 모르는 상태입니다.
추정문제이기 때문에 MLE 에서는 이 $\theta$를 추정하는 것을 목표로 합니다.
우리가 위에서 모수에 대해서 언급을 했는데, 통계학에서 말하는 조사는 2가지 방식이 있습니다.
- 전수 조사
- 표본 조사
전수 조사란, 말 그대로 모든 수에 대해서 조사하는 방식입니다.
우리가 예를 들어 설문조사를 한다고 하면, 전 국민에게 모든 응답을 들어서 통계적으로 나타내는 것이 전수 조사입니다.
하지만 통계학은 이렇게 전수 조사를 하지 않더라도 predict 하여 대략적인 근사 결과를 알 수 있는데, 이를 표본을 추출하여(sampling) 조사하는 표본 조사입니다.
표본을 조사함으로써, 모집단의 특성(평균과 표준편차)을 파악하는 것을 “Estimation”, 추정이라고 합니다.
최대 우도(= 최대 가능도, Maximum Likelihood)를 추정하려면 질문이 조금 바뀌게 됩니다.
원래 “구름이 흐릴 때 비가 올 확률이 얼마나 될까?” 가 질문이었다면, 추정 문제에서는 “만약 비가 온다면, 구름의 상태는 얼마나 흐린 상태일까?” 가 됩니다.
다시 말해서, 어떠한 상태가 주어지고 그 상태가 어느 확률 분포에 포함될 가능성이 가장 높은지 추정하는 것 이 “최대 우도 추정” 입니다.
이게 GAN framework와 어떤 관련이 있느냐? 라고 한다면, 이제 생각해 볼 수 있습니다.
- Discriminator는 입력 이미지가 정답 데이터셋의 분포에 포함되는 지 판별하는 판별자입니다.
- Generator는 Discriminator를 속여야 합니다.
다시 말해서, Generator로 생성된 이미지는 Disriminator가 그 이미지를 보고 “아, MLE로 생각해 보았을 때, 정답 데이터셋의 분포에 있을 가능도가 가장 높아 → True Dataset이야!” 라고 속일 수 있어야 합니다.
그러면 이번에는, Discriminator는 그 서로 다른 확률 분포를 어떻게 알 수 있을까요?
여기서 사용되는 것이 KL-Divergence (쿨백-라이블러 발산) 입니다.