Let's put the concepts of neurons, weights, biases, and activation functions into practice. Understanding how to calculate the output of a single neuron is fundamental, as this exact process is repeated for every neuron in a network during forward propagation.
Recall the two main steps for a neuron's computation:
Imagine a single neuron with two inputs. Let's define its parameters and the input values:
We multiply each input by its corresponding weight, sum these products, and add the bias:
z=(w1×x1)+(w2×x2)+b z=(0.5×2.0)+(−1.0×3.0)+1.0 z=1.0−3.0+1.0 z=−1.0
So, the result of the linear combination is z=−1.0.
Visualizing the inputs, weights, and bias feeding into the calculation of the linear combination (z) and the subsequent activation (a).
Now, we apply an activation function to z=−1.0. The output a will depend on which function we choose. Let's calculate the output using the three common functions we discussed: Sigmoid, Tanh, and ReLU.
Sigmoid: The Sigmoid function squashes the input into a range between 0 and 1. a=σ(z)=1+e−z1 a=1+e−(−1.0)1=1+e1.01 Using e≈2.71828: a≈1+2.718281=3.718281≈0.2689 So, if using Sigmoid, the neuron's output is approximately 0.2689.
Tanh (Hyperbolic Tangent): Tanh squashes the input into a range between -1 and 1. a=tanh(z)=ez+e−zez−e−z a=e−1.0+e1.0e−1.0−e1.0 Using e1.0≈2.71828 and e−1.0≈0.36788: a≈0.36788+2.718280.36788−2.71828=3.08616−2.3504≈−0.7616 If using Tanh, the neuron's output is approximately −0.7616.
ReLU (Rectified Linear Unit): ReLU outputs the input directly if it's positive, and 0 otherwise. a=ReLU(z)=max(0,z) a=max(0,−1.0) a=0 If using ReLU, the neuron's output is 0.
For the given inputs x=[2.0,3.0], weights w=[0.5,−1.0], and bias b=1.0, we first found z=−1.0. The final neuron output a depends on the chosen activation function:
This exercise demonstrates the core calculation performed by every artificial neuron. In a real network, the output a from this neuron could then become an input x for neurons in the next layer. Try changing the input values, weights, or bias and recalculate the outputs using different activation functions to solidify your understanding. This simple operation, repeated many times across layers, is what allows neural networks to process information and learn complex patterns.
© 2025 ApX Machine Learning