Lecture 2 - Neural Network v1.0
Lecture 2 - Neural Network v1.0
0”
Jim Kyung-Soo Liew, Ph.D.
Associate Professor in Finance
President of SoKat
Spring II 2025
Lecture 2 – Neural Network Details
Assignment 2
1) Redo building a Neural Network (e.g. myFirstMNIST.ipynb) but instead of using the MNIST data as we did in-
class, employ the FashionMNIST data. Increase the accuracy of NN model by adjusting architectural structure,
etc. Advanced students should re-code everything, understand each line of the code. (Submit code)
2) Read the blog “Imperial College ML – NN”; explain concepts that you found interesting, what did you learn?
(1/2 page)
• What is the XOR problem, who showed it was impossible for the perceptron to solve it? Why?
• What is the depth of a network, what about width?
• What happens if we initialize all the parameters to zero (all wgts and biases)?
• What’s the difference between binary cross entropy and negative log likelihood loss function?
• What is the vanishing gradient problem?
• Describe regularization? What is dropout?
3) Watch and summarize -- https://www.youtube.com/watch?v=ErnWZxJovaM (1/2 page)
4) Vibe Code Assignment 2 – “Elon Fired!” (Submit 3-min video narrative and code)
X1
X2
X3
X4
X1
Cell Nucleus
X2
X3
X4
X1
X3
X4
X1
X3
X4
Perceptron
Perceptron
Perceptron
Perceptron
Perceptron
three Perceptron
Perceptron
Perceptron
three Perceptron
four Perceptron
Daniel Khashabi 17
Feedforward networks
This is a particular class called “feedforward” networks.
o Cascade neurons together
Weights to learn!
Weights to learn!
Weights to learn!
https://playground.tensorflow.org
3/31/2025 @Prof Jim Liew 27
Activation Functions - Sigmoid
1
𝑓𝑓 𝑥𝑥 =
1 + 𝑒𝑒 −𝑥𝑥
𝑒𝑒 𝑥𝑥 − 𝑒𝑒 −𝑥𝑥
𝑓𝑓 𝑥𝑥 = 𝑥𝑥
𝑒𝑒 + 𝑒𝑒 −𝑥𝑥
𝑓𝑓 𝑥𝑥 = 𝑚𝑚𝑚𝑚𝑚𝑚 0, 𝑥𝑥
𝑛𝑛
1 2
𝑀𝑀𝑀𝑀𝑀𝑀 = � 𝑦𝑦𝑖𝑖 − 𝑦𝑦�𝑖𝑖
𝑛𝑛
𝑖𝑖=1
𝑛𝑛
1
𝐵𝐵𝐵𝐵𝐵𝐵 = − � 𝑦𝑦𝑖𝑖 log 𝑦𝑦�𝑖𝑖 + 1 − 𝑦𝑦𝑖𝑖 log 1 − 𝑦𝑦�𝑖𝑖
𝑛𝑛
𝑖𝑖=1
𝑛𝑛 𝑚𝑚
Output
Pixels: 28 x 28 = 784
Output
Layer
37
Neural Network structure
Output
Pixels: 28 x 28 = 784
Output
Layer
38
Neural Network structure
Output
Pixels: 28 x 28 = 784
Output
Layer
39
Training process – Forward Propagation
Epoch 1
Output
Batch 1
Batch 2
Forward propagation -Compare with
Batch 3 Truth
-Calculate the Loss
…
Batch n
Training Output
Data Layer
40
Training process – Back Propagation
Epoch 1
Output
Batch 1
Batch 2
Forward propagation -Compare with
Batch 3 Truth
-Calculate the Loss
…
Back propagation
Batch n
Training Output
Data Layer
41
Backprop intuition
σ(z)
Initial parameters:
• Weight 1 (w₁) = 0.5 σ(z)
• Weight 2 (w₂) = 0.5
3/31/2025 0.365529
@Prof Jim Liew 48
Backward Pass – The Chain Rule in Action
https://www.doc.ic.ac.uk/~nuric/posts/teaching/imperial-college-machine-learning-neural-networks
3/31/2025 @Prof Jim Liew 58
Gradient Descent
https://www.doc.ic.ac.uk/~nuric/posts/teaching/imperial-college-machine-learning-neural-networks
3/31/2025 @Prof Jim Liew 59
Under vs Over Fitting
.fit() train
.evaluate() to test
Overfitting and regularization techniques