Neural - N - Problems - MLP
Neural - N - Problems - MLP
Neural - N - Problems - MLP
Back Propagation
Steps of a single epoch
For each pattern
• Forward prop
o Calculate 𝑛𝑒𝑡𝑗 and 𝑜𝑗 for all neurons (except input layer and bias neurons)
o Calculate specific error (for single pattern)
• Back prop
o Calculate 𝛿𝑗 for all neurons (except input layer and bias neurons)
o Calculate ∆𝑤𝑖,𝑗 for all variable weights including bias weights
o 𝑤𝑖,𝑗 ≔ 𝑤𝑖,𝑗 + ∆𝑤𝑖,𝑗
After end of epoch
• Calculate total error = sum of specific errors
• Check stopping condition
• Run another epoch if stopping condition is False
Notes Assuming layer K is before layer H, and either layer L is after
layer H, or layer H is the output layer
• Forward prop:
o net3 = w13 * x1 + w23 * x2 + wb3 = 0.3 * 0 – 0.1 * 0 + 0.2 = 0.2
o o3 = 1/(1 + e^-net3) = 1/(1 + e^-0.2) = 0.5498
o net4 = w14 * x1 + w24 * x2 + wb4 = -0.2 * 0 + 0.2 * 0 – 0.3 = -0.3
o o4 = 1/(1 + e^-net4) = 1/(1 + e^0.3) = 0.4256
o net5 = w35 * o3 + w45 * o4 + wb5 = 0.4 * 0.5498 – 0.2 * 0.4256 + 0.4 = 0.5348
o y = 1/(1+e^-net5) = 1/(1+e^-0.5348) = 0.6306
• Calculating error:
o Err_p1 = 0.5 * (0 – 0.6306)^2 = 0.1988
Epoch: 1
Pattern: 1: x1 = 0, x2 = 0, t = 0
Back Prop:
1) Finding delta
δ5 = y*(1 - y)*(t - y) = 0.6306 * (1 - 0.6306) * (0 - 0.6306) = - 0.1469
δ3 = o3(1 – o3)* δ5 * w35 = 0.5498 * (1 - 0.5498) * - 0.1469 * 0.4 = - 0.0145
δ4 = o4(1 – o4)* δ5 * w45 = 0.4256 * (1 - 0.4256) * - 0.1469 * -0.2 = 0.0072
• Forward prop:
o net3 = w13 * x1 + w23 * x2 + wb3 = …
o o3 = 1/(1 + e^-net3) = …
o net4 = w14 * x1 + w24 * x2 + wb4 = …
o o4 = 1/(1 + e^-net4) = …
o net5 = w35 * o3 + w45 * o4 + wb5 = …
o y = 1/(1+e^-net5) = …
• Calculating error:
o Err_p2 = 0.5 * (t – y)^2 = …
Epoch: 1
Pattern: 2: x1 = 0, x2 = 1, t = 1
Back Prop:
1) Finding delta
δ5 = y*(1 - y)*(t - y) = …
δ3 = o3(1 – o3)* δ5 * w35 = …
δ4 = o4(1 – o4)* δ5 * w45 = …
• Forward prop:
o net3 = w13 * x1 + w23 * x2 + wb3 = …
o o3 = 1/(1 + e^-net3) = …
o net4 = w14 * x1 + w24 * x2 + wb4 = …
o o4 = 1/(1 + e^-net4) = …
o net5 = w35 * o3 + w45 * o4 + wb5 = …
o y = 1/(1+e^-net5) = …
• Calculating error:
o Err_p3 = 0.5 * (t – y)^2 = …
Epoch: 1
Pattern: 3: x1 = 1, x2 = 0, t = 1
Back Prop:
1) Finding delta
δ5 = y*(1 - y)*(t - y) = …
δ3 = o3(1 – o3)* δ5 * w35 = …
δ4 = o4(1 – o4)* δ5 * w45 = …
• Forward prop:
o net3 = w13 * x1 + w23 * x2 + wb3 = …
o o3 = 1/(1 + e^-net3) = …
o net4 = w14 * x1 + w24 * x2 + wb4 = …
o o4 = 1/(1 + e^-net4) = …
o net5 = w35 * o3 + w45 * o4 + wb5 = …
o y = 1/(1+e^-net5) = …
• Calculating error:
o Err_p4 = 0.5 * (t – y)^2 = …
Epoch: 1
Pattern: 4: x1 = 1, x2 = 1, t = 0
Back Prop:
1) Finding delta
δ5 = y*(1 - y)*(t - y) = …
δ3 = o3(1 – o3)* δ5 * w35 = …
δ4 = o4(1 – o4)* δ5 * w45 = …
If epoch number = max number of epochs (if given): Then stop training