Excellent! Let's proceed with how data flows through the network during theforward propagationphase.
For our example, let's assume the following (randomly chosen) weights and biases for our network:
Weights from Input Layer to Hidden Layer:w1=0.5,w2=0.5,w1=0.5,w2=−0.2,w3=0.1,w4=0.1,w3=0.1,w4=0.9,w5=−0.3,w6=0.8w_{1} = 0.5, w_{2} = -0.2, w_{3} = 0.1, w_{4} = 0.9, w_{5} = -0.3, w_{6} = 0.8w1=0.5,w2=−0.2,w3=0.1,w4=0.9,w5=−0.3,w6=0.8
Biases in Hidden Layer:b1=0.1,b2=0.1,b1=0.1,b2=−0.2,b3=0.2b_{1} = 0.1, b_{2} = -0.2, b_{3} = 0.2b1=0.1,b2=−0.2,b3=0.2
Weights from Hidden Layer to Output Layer:w7=−0.3,w8=0.2,w9=0.2,w8=0.2,w9=0.7w_{7} = -0.3, w_{8} = 0.2, w_{9} = 0.7w7=−0.3,w8=0.2,w9=0.7
Bias in Output Layer:b4=0.1b_{4} = 0.1b4=0.1
Weights from Input Layer to Hidden Layer:w1=0.5,w2=0.5,w1=0.5,w2=−0.2,w3=0.1,w4=0.1,w3=0.1,w4=0.9,w5=−0.3,w6=0.8w_{1} = 0.5, w_{2} = -0.2, w_{3} = 0.1, w_{4} = 0.9, w_{5} = -0.3, w_{6} = 0.8w1=0.5,w2=−0.2,w3=0.1,w4=0.9,w5=−0.3,w6=0.8
Biases in Hidden Layer:b1=0.1,b2=0.1,b1=0.1,b2=−0.2,b3=0.2b_{1} = 0.1, b_{2} = -0.2, b_{3} = 0.2b1=0.1,b2=−0.2,b3=0.2
Weights from Hidden Layer to Output Layer:w7=−0.3,w8=0.2,w9=0.2,w8=0.2,w9=0.7w_{7} = -0.3, w_{8} = 0.2, w_{9} = 0.7w7=−0.3,w8=0.2,w9=0.7
Bias in Output Layer:b4=0.1b_{4} = 0.1b4=0.1
Suppose we have an input data point: an animal with a height of 20 cm and a tail length of 15 cm. Here's how we would calculate the output of the first node in the hidden layer:
Multiply each input by the corresponding weight:(20⋅0.5)+(15⋅0.1)(20 \cdot 0.5) + (15 \cdot 0.1)(20⋅0.5)+(15⋅0.1)
Add the bias:(20⋅0.5)+(15⋅0.1)+0.1(20 \cdot 0.5) + (15 \cdot 0.1) + 0.1(20⋅0.5)+(15⋅0.1)+0.1
Apply the activation function. For simplicity, let's use the ReLU (Rectified Linear Unit) activation function, which returns the input if it's positive and 0 otherwise:max(0,(20⋅0.5)+(15⋅0.1)+0.1)\max(0, (20 \cdot 0.5) + (15 \cdot 0.1) + 0.1)max(0,(20⋅0.5)+(15⋅0.1)+0.1)
Multiply each input by the corresponding weight:(20⋅0.5)+(15⋅0.1)(20 \cdot 0.5) + (15 \cdot 0.1)(20⋅0.5)+(15⋅0.1)
Add the bias:(20⋅0.5)+(15⋅0.1)+0.1(20 \cdot 0.5) + (15 \cdot 0.1) + 0.1(20⋅0.5)+(15⋅0.1)+0.1
Apply the activation function. For simplicity, let's use the ReLU (Rectified Linear Unit) activation function, which returns the input if it's positive and 0 otherwise:max(0,(20⋅0.5)+(15⋅0.1)+0.1)\max(0, (20 \cdot 0.5) + (15 \cdot 0.1) + 0.1)max(0,(20⋅0.5)+(15⋅0.1)+0.1)
We would repeat these steps for each node in the hidden layer, and then repeat the process to calculate the output of the node in the output layer.
Duringbackpropagation, the network adjusts the weights and biases to minimize the difference between the network's output and the true value for each input. The network calculates the derivative of the loss function with respect to each weight and bias (i.e., the gradient), then adjusts the weights and biases by a small step in the direction that most decreases the loss. This is done using an optimization algorithm like Gradient Descent.