PY_2_Define
PY_2_Define
Definition:
An Artificial Neural Network (ANN) is a computational model that mimics the
structure and behavior of the human brain. It is composed of interconnected units
called neurons, organized into layers. These networks can learn from data,
identify patterns, and make decisions.
5. Layers:
Working:
Each neuron receives inputs, applies weights and bias, sums the result, applies an
activation function, and passes the output to the next layer.
Example:
Supervised Learning Example: Input: Image of a cat → Label: “Cat” Model
learns from input-output pairs to predict future labels.
🔹 Key Idea:
It finds patterns in data and organizes similar input patterns into nearby locations
on the map (a grid of neurons).
🔹 Architecture:
1. Input Layer:
o Calculate distance (usually Euclidean) between the input vector and all
neurons’ weight vectors.
4. Best Matching Unit (BMU):
o Select the neuron whose weights are closest to the input → called
BMU.
5. Weight Update:
o Update the weights of the BMU and its neighboring neurons to move
closer to the input.
o Update rule:
where:
o Neurons closer to the BMU are updated more than those further
away.
7. Repeat:
🔹 Example:
Suppose you have a dataset of customers with features like age, income, and
purchase behavior. A Kohonen SOM can group similar customers on a 2D map,
visually showing clusters of similar profiles.
📌 Initial conditions:
Initial weights: w 1=0 , w 2=0 , θ=0
Learning rate η=1
Where:
T = Target output
O = Actual output using activation function
O= {−1
+1 if n e t ≥ 0
if n e t <0
n e t=w1 x1 + w2 x 2 −θ
🔁 Epoch 1:
Pattern 1: (1, 1) → Target = 1
Net = 0∗1+0∗1− 0=0 → Output = +1 ✅ (No change since output matches
target)
Pattern 2: (1, -1) → Target = -1
Net = 0∗1+0∗(− 1)−0=0 → Output = +1 ❌
Error = -1 - (+1) = -2
Update: w 1=0+1∗(− 2)∗1=− 2 w 2=0+1∗(− 2)∗(− 1)=2 θ=0+1∗(−2)∗(−1)=2
Pattern 3: (-1, 1) → Target = -1
Net = −2∗(− 1)+2∗1 −2=2+2 −2=2 → Output = +1 ❌
Error = -1 - (+1) = -2
Update: w 1=−2+1∗(− 2)∗(− 1)=0 w 2=2+1∗(−2)∗1=0 θ=2+1∗(−2)∗(−1)=4
Pattern 4: (-1, -1) → Target = -1
Net = 0∗(− 1)+0∗(−1)− 4=− 4 → Output = -1 ✅ (No change)
🔁 Epoch 2:
Pattern 1: (1, 1) → Target = 1
Net = 0+ 0− 4=− 4 → Output = -1 ❌
Error = 1 - (-1) = 2
Update: w 1=0+2∗1=2 w 2=0+2∗1=2 θ=4 +2∗(−1)=2
Pattern 2: (1, -1) → Target = -1
Net = 2∗1+ 2∗(−1)− 2=2 −2 −2=− 2 → Output = -1 ✅ (No change)
Pattern 3: (-1, 1) → Target = -1
Net = −2+2 − 2=−2 → Output = -1 ✅ (No change)
Pattern 4: (-1, -1) → Target = -1
Net = −2+(−2)−2=− 6 → Output = -1 ✅ (No change)
✅ Final Weights:
w 1=2
w 2=2
θ=2
O= {
+1 if 2 x1 +2 x 2 ≥ 2
−1 otherwise
Let me know if you want this in a Python implementation or need explanation for
a different part!