# F25 Q2a

Subject: Deep Learning

Exam: TEE

Reader: https://deep-learning-study-room.vercel.app/#tee/read/11/tee-c11-s4

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

## Question

**Question (10 marks).** A 2 → 2 → 1 sigmoid network has all four input-to-hidden weights 0.5, both hidden-to-output weights 0.25, hidden and output biases 0, and target 1. Perform forward and backward passes to update the x₁ → h₁ weight, h₁ → output weight and output bias at η = 0.5. The paper does not state the numerical inputs or loss.

![F25 Q2a connections with explicitly assumed inputs](https://deep-learning-study-room.vercel.app/assets/figures/net_f25.svg)

Diagram: F25 Q2a connections with explicitly assumed inputs. Labels: Read each receiving neuron as one row of weights | INPUT | HIDDEN | OUTPUT | x1=1 | x2=1 | h1 | h2 | o1 | target 1 | h1 incoming: x1 × 0.5 + x2 × 0.5; bias 0 | h2 incoming: x1 × 0.5 + x2 × 0.5; bias 0 | o1 incoming: h1 × 0.25 + h2 × 0.25; bias 0 | Use these OLD connections for all gradients in the same pass.

F25 Q2a connections with explicitly assumed inputs Tap the diagram to enlarge.

## Answer — step by step

### Given

Architecture 2 → 2 → 1; every neuron uses sigmoid.

All four input-to-hidden weights = 0.5; both hidden-to-output weights = 0.25.

All biases = 0; target = 1; η = 0.5.

The paper omits inputs and loss: this worked solution explicitly assumes x = [1,1] and half squared loss.

### To find

Calculate the forward pass, then gradients and updates for x₁→h₁, h₁→output and the output bias.

### Formula — which one and why

**Forward propagation.** Evaluate one layer completely before supplying its activated outputs to the next layer. Each layer has its own weights and biases.

x = input vector; h = hidden outputs; W₁,b₁ = hidden parameters; W₂,b₂ = output parameters; f₁,f₂ = the stated activations.



$$
z_h=W_1x+b_1
$$





$$
h=f_1(z_h)
$$





$$
z_o=W_2h+b_2
$$





$$
o=f_2(z_o)
$$



**Yaad rakhne ka cue:** Pehli layer ka activated output hi agli layer ka input hai.

**Half summed squared loss.** This loss convention takes one-half of the sum of squared prediction errors. Use it when the question specifies it, or explicitly state it as an assumption when the paper omits the loss. Differentiating cancels the factor one-half against the square derivative.

oⱼ = output j; yⱼ = target j; L = half summed squared loss under the stated or explicitly assumed convention.



$$
L=\frac12\sum_j(o_j-y_j)^2
$$





$$
\frac{\partial L}{\partial o_j}=o_j-y_j
$$



**Yaad rakhne ka cue:** Half aur square ka 2 cancel: output derivative = prediction − target.

**Sigmoid and its slope.** Use sigmoid when the neuron is specified to squash its preactivation into (0,1). Once its output is known, its derivative needs only output × (1−output).

z = preactivation; p = sigmoid output; e is the exponential base, not a prediction error in this formula.



$$
p=\frac{1}{1+e^{-z}}
$$





$$
\frac{dp}{dz}=p(1-p)
$$



**Yaad rakhne ka cue:** Sigmoid output p; uska slope p × (1−p).

**Backpropagation.** The loss tells us how each output must change. Multiply by that neuron’s activation slope to obtain its delta. A weight gradient is receiving delta × sending value. Hidden deltas must include every outgoing path.

δ (delta) = derivative of loss with respect to a neuron’s preactivation; f′ = activation derivative; aᵢ = sending activation; Wⱼᵢ = connection weight. Use the exact loss scaling in the question.



$$
\delta_{o_j}=\frac{\partial L}{\partial o_j}f_o\prime(z_{o_j})
$$





$$
\delta_{h_i}=f_h\prime(z_{h_i})\sum_jW_{ji}^{(2)}\delta_{o_j}
$$





$$
\frac{\partial L}{\partial W_{ji}}=\delta_ja_i
$$





$$
\frac{\partial L}{\partial b_j}=\delta_j
$$





$$
W_{ji,\mathrm{new}}=W_{ji}-\eta\frac{\partial L}{\partial W_{ji}}
$$



**Yaad rakhne ka cue:** Receiving delta × sending value = us connection ka gradient.

### Solution — step by step

**Assumptions:**  use x = [1,1] and half squared loss. The paper permits suitable assumptions and its key also introduces assumed inputs. There is no unique numerical result without them.

**Step 1 map the arrows.** Each row of W₁ receives all inputs; each row of W₂ receives all hidden outputs. Bias is added once per receiving neuron. All gradients below use the OLD weights from this same forward pass.

**Hidden neuron 1:**



$$
z_{h_1} = (0.5 \times  1) + (0.5 \times  1) + (0) = 1
$$





$$
h_{1}=\frac{1}{1+e^{-(1)}}=0.731058579
$$



**Hidden neuron 2:**



$$
z_{h_2} = (0.5 \times  1) + (0.5 \times  1) + (0) = 1
$$





$$
h_{2}=\frac{1}{1+e^{-(1)}}=0.731058579
$$



**Output neuron 1:**



$$
z_{o_1} = (0.25 \times  0.731058579) + (0.25 \times  0.731058579) + (0) = 0.365529289
$$





$$
o_{1}=\frac{1}{1+e^{-(0.365529289)}}=0.590378257
$$



**Step 2 loss convention.** This worked solution uses half summed squared loss, L = ½Σ(o − y)². Follow the loss specified in the question; where none is supplied, this is an explicit assumption.

Prediction minus target = [-0.409621743]. Squared errors = [0.167789972]. Half-sum squared loss = 0.083894986; mean squared error = 0.167789972. These are different unless the number of output components makes the scale coincide.

**Output delta 1:**



$$
\delta_{o_1} = 1 \times  (0.590378257-1) \times  0.241831771 = -0.099059551
$$



The derivative is o(1−o).

**Step 3 output weights.** Gradient = receiving delta × sending activation. An output bias gradient equals its delta.

**h1 → o1:**

The calculation on h1 → o1

Sending activation**0.731058579**h1

×

Receiving delta**−0.099059551**δ at o1

=

Connection gradient**−0.072418335**h1 → o1

Now update this weight

Old weight**0.25**

→

New weight**0.286209167**

Subtract η × gradient = **−0.036209168**. This weight **increases**.

The sending value and receiving delta have different roles. All deltas still use the original forward-pass weights.

The receiving neuron supplies the delta; the sending neuron supplies its activation.



$$
g_{1,1}^{(2)}=\frac{\partial L}{\partial W^{(2)}_{1,1}}=\delta_{o_1}h_1
$$





$$
g_{1,1}^{(2)}=(-0.099059551)\times(0.731058579)\approx -0.072418335
$$



Apply the learning rate to this gradient and subtract the result from the old weight.



$$
W^{(2)}_{1,1,\mathrm{new}}=0.25-0.5(-0.072418335)\approx 0.286209167
$$



**h2 → o1:**

The calculation on h2 → o1

Sending activation**0.731058579**h2

×

Receiving delta**−0.099059551**δ at o1

=

Connection gradient**−0.072418335**h2 → o1

Now update this weight

Old weight**0.25**

→

New weight**0.286209167**

Subtract η × gradient = **−0.036209168**. This weight **increases**.

The sending value and receiving delta have different roles. All deltas still use the original forward-pass weights.

The receiving neuron supplies the delta; the sending neuron supplies its activation.



$$
g_{1,2}^{(2)}=\frac{\partial L}{\partial W^{(2)}_{1,2}}=\delta_{o_1}h_2
$$





$$
g_{1,2}^{(2)}=(-0.099059551)\times(0.731058579)\approx -0.072418335
$$



Apply the learning rate to this gradient and subtract the result from the old weight.



$$
W^{(2)}_{1,2,\mathrm{new}}=0.25-0.5(-0.072418335)\approx 0.286209167
$$



**Step 4 hidden deltas.** A hidden unit can influence EVERY connected output, so add those paths BEFORE multiplying by the hidden activation derivative.

**Hidden 1 downstream contribution:**

Calculate each outgoing path using the **old** outgoing weight and that output's delta.

Several output paths meet at this hidden neuron

Output 1

Output delta**−0.099059551**

×

Old outgoing weight**0.25**

=

Path contribution**−0.024764888**

↓

Add every path contribution**−0.024764888**Then multiply by the hidden activation derivative.

Multiply within each path. Add the resulting contributions at the shared hidden neuron.

**Contribution from output 1.**



$$
C_1=(0.25)\times(-0.099059551)\approx -0.024764888
$$



**Accumulate the contributions, then apply the hidden activation derivative below.**



$$
\text{Sum}=C_1\approx -0.024764888
$$





$$
\delta_{h_1} = -0.024764888 \times  0.196611933 = -0.004869072
$$



**Hidden 2 downstream contribution:**

Calculate each outgoing path using the **old** outgoing weight and that output's delta.

Several output paths meet at this hidden neuron

Output 1

Output delta**−0.099059551**

×

Old outgoing weight**0.25**

=

Path contribution**−0.024764888**

↓

Add every path contribution**−0.024764888**Then multiply by the hidden activation derivative.

Multiply within each path. Add the resulting contributions at the shared hidden neuron.

**Contribution from output 1.**



$$
C_1=(0.25)\times(-0.099059551)\approx -0.024764888
$$



**Accumulate the contributions, then apply the hidden activation derivative below.**



$$
\text{Sum}=C_1\approx -0.024764888
$$





$$
\delta_{h_2} = -0.024764888 \times  0.196611933 = -0.004869072
$$



**Step 5 input weights.** Multiply the hidden delta by the corresponding raw input, not by the hidden output.

**x1 → h1:**

The calculation on x1 → h1

Sending input**1**x1

×

Receiving delta**−0.004869072**δ at h1

=

Connection gradient**−0.004869072**x1 → h1

Now update this weight

Old weight**0.5**

→

New weight**0.502434536**

Subtract η × gradient = **−0.002434536**. This weight **increases**.

The sending value and receiving delta have different roles. All deltas still use the original forward-pass weights.

The receiving neuron supplies the delta; the sending neuron supplies the input value.



$$
g_{1,1}^{(1)}=\frac{\partial L}{\partial W^{(1)}_{1,1}}=\delta_{h_1}x_1
$$





$$
g_{1,1}^{(1)}=(-0.004869072)\times(1)\approx -0.004869072
$$



Apply the learning rate to this gradient and subtract the result from the old weight.



$$
W^{(1)}_{1,1,\mathrm{new}}=0.5-0.5(-0.004869072)\approx 0.502434536
$$



**x2 → h1:**

The calculation on x2 → h1

Sending input**1**x2

×

Receiving delta**−0.004869072**δ at h1

=

Connection gradient**−0.004869072**x2 → h1

Now update this weight

Old weight**0.5**

→

New weight**0.502434536**

Subtract η × gradient = **−0.002434536**. This weight **increases**.

The sending value and receiving delta have different roles. All deltas still use the original forward-pass weights.

The receiving neuron supplies the delta; the sending neuron supplies the input value.



$$
g_{1,2}^{(1)}=\frac{\partial L}{\partial W^{(1)}_{1,2}}=\delta_{h_1}x_2
$$





$$
g_{1,2}^{(1)}=(-0.004869072)\times(1)\approx -0.004869072
$$



Apply the learning rate to this gradient and subtract the result from the old weight.



$$
W^{(1)}_{1,2,\mathrm{new}}=0.5-0.5(-0.004869072)\approx 0.502434536
$$



**x1 → h2:**

The calculation on x1 → h2

Sending input**1**x1

×

Receiving delta**−0.004869072**δ at h2

=

Connection gradient**−0.004869072**x1 → h2

Now update this weight

Old weight**0.5**

→

New weight**0.502434536**

Subtract η × gradient = **−0.002434536**. This weight **increases**.

The sending value and receiving delta have different roles. All deltas still use the original forward-pass weights.

The receiving neuron supplies the delta; the sending neuron supplies the input value.



$$
g_{2,1}^{(1)}=\frac{\partial L}{\partial W^{(1)}_{2,1}}=\delta_{h_2}x_1
$$





$$
g_{2,1}^{(1)}=(-0.004869072)\times(1)\approx -0.004869072
$$



Apply the learning rate to this gradient and subtract the result from the old weight.



$$
W^{(1)}_{2,1,\mathrm{new}}=0.5-0.5(-0.004869072)\approx 0.502434536
$$



**x2 → h2:**

The calculation on x2 → h2

Sending input**1**x2

×

Receiving delta**−0.004869072**δ at h2

=

Connection gradient**−0.004869072**x2 → h2

Now update this weight

Old weight**0.5**

→

New weight**0.502434536**

Subtract η × gradient = **−0.002434536**. This weight **increases**.

The sending value and receiving delta have different roles. All deltas still use the original forward-pass weights.

The receiving neuron supplies the delta; the sending neuron supplies the input value.



$$
g_{2,2}^{(1)}=\frac{\partial L}{\partial W^{(1)}_{2,2}}=\delta_{h_2}x_2
$$





$$
g_{2,2}^{(1)}=(-0.004869072)\times(1)\approx -0.004869072
$$



Apply the learning rate to this gradient and subtract the result from the old weight.



$$
W^{(1)}_{2,2,\mathrm{new}}=0.5-0.5(-0.004869072)\approx 0.502434536
$$



**Step 6 bias updates.** A bias receives a constant input 1, so its gradient equals the corresponding delta. Use the same old forward pass and learning rate as the weight updates.



$$
b_{h_1,\mathrm{new}}=0-0.5(-0.004869072)=0.002434536
$$





$$
b_{h_2,\mathrm{new}}=0-0.5(-0.004869072)=0.002434536
$$





$$
b_{o_1,\mathrm{new}}=0-0.5(-0.099059551)=0.049529775
$$



These are independent per-neuron biases. If the question fixes biases, keep them fixed. If it specifies a single tied bias, add all deltas sharing that bias before updating it.

**Requested values:**  input weight **0.502434536**, output weight **0.286209167**, output bias **0.049529775**. Other supplied inputs produce different correct conditional results.
