# Drill 2 Half sum versus mean

Subject: Deep Learning

Exam: TEE

Reader: https://deep-learning-study-room.vercel.app/#tee/read/17/tee-c17-s2

Canonical: https://deep-learning-study-room.vercel.app/read/dl/tee/section/tee-c17-s2/

## Question

**Question.** Predictions = [0.2,0.7,0.4], targets = [0,1,1]. Find SSE, half SSE and MSE.

## Answer — step by step

### Given

Predictions = [0.2, 0.7, 0.4].

Targets = [0, 1, 1]; number of outputs n = 3.

### To find

Find SSE, half SSE, MSE and the prediction gradients requested in the question.

### Formula — which one and why

**Squared-error objectives.** Calculate signed errors first and square them. SSE adds the squares; half SSE divides that sum by 2; MSE divides by the number of scalar predictions. These denominators are different conventions.

ŷᵢ = prediction; yᵢ = target; eᵢ = signed error; n = number of scalar predictions included in the stated loss.



$$
e_i=\hat y_i-y_i
$$





$$
\mathrm{SSE}=\sum_i e_i^2
$$





$$
L_{\mathrm{half}}=\frac12\sum_i e_i^2
$$





$$
\mathrm{MSE}=\frac1n\sum_i e_i^2
$$



**Yaad rakhne ka cue:** Pehle error square; phir question ke hisaab se sum, half ya mean.

### Solution — step by step

### Given values and loss definitions

There are n = 3 prediction–target pairs. Use the supplied predictions directly; no rounding to class labels is required. Let eᵢ = ŷᵢ − yᵢ be the signed residual for pair i.



$$
\mathrm{SSE}=\sum_{i=1}^{n}e_i^2
$$





$$
L_{\mathrm{half}}=\frac12\sum_{i=1}^{n}e_i^2=\frac{\mathrm{SSE}}2
$$





$$
\mathrm{MSE}=\frac1n\sum_{i=1}^{n}e_i^2=\frac{\mathrm{SSE}}n
$$



SSE is the sum of squared errors. Half SSE and MSE rescale that same sum by different denominators: 2 and n, respectively.

### Step 1: calculate each residual and its square

| Pair | Prediction ŷᵢ | Target yᵢ | Residual ŷᵢ − yᵢ | Squared residual |
| --- | --- | --- | --- | --- |
| 1 | 0.2 | 0 | 0.2 − 0 = 0.2 | (0.2)² = 0.04 |
| 2 | 0.7 | 1 | 0.7 − 1 = −0.3 | (−0.3)² = 0.09 |
| 3 | 0.4 | 1 | 0.4 − 1 = −0.6 | (−0.6)² = 0.36 |

### Step 2: sum the squared residuals



$$
\mathrm{SSE}=0.04+0.09+0.36=0.49
$$



Square each residual before summing. Squaring the sum of signed residuals would be a different quantity, because positive and negative residuals could cancel.

### Step 3: apply each requested normalization

For half SSE, the denominator is 2:



$$
L_{\mathrm{half}}=\frac{0.49}{2}=0.245
$$



For MSE, the denominator is the number of pairs, n = 3:



$$
\mathrm{MSE}=\frac{0.49}{3}=0.163333333\ldots
$$



**Final answer:** SSE = 0.49; half SSE = 0.245; MSE ≈ 0.163333. They represent the same residuals at different scales. Half SSE and MSE coincide when n = 2; they do not coincide for these three nonzero residuals. No derivative is required by this question.
