Interactive Neuron

1. Inputs
2. Weights
3. Sum
4. Bias
5. Activation
6. Output
Ready
Click "Run Animation" to see how a neuron computes its output

Adjust Inputs

0.5
-0.3
0.8

Understanding the Neuron

Think of it like voting: Each input is a voter with a different level of influence (weight). The neuron tallies the weighted votes, adds its own bias, then decides whether to "fire" based on the total.

Step 1: Inputs (x₁, x₂, x₃)

The neuron receives multiple input values. In CartPole, these are the state values: cart position, velocity, pole angle, and angular velocity.

Step 2: Weights (w₁, w₂, w₃)

Each input has an associated weight that determines its importance. Positive weights amplify, negative weights suppress. These weights are what the network learns during training.

Step 3: Weighted Sum

Multiply each input by its weight and sum them all:

sum = x₁×w₁ + x₂×w₂ + x₃×w₃

Step 4: Add Bias

The bias shifts the activation threshold. It lets the neuron fire even when inputs are zero, or require stronger inputs to fire.

z = sum + bias

Step 5: Activation Function (ReLU)

ReLU (Rectified Linear Unit) is simple: if the value is positive, keep it; if negative, output zero.

def relu(z): return max(0, z)
Why ReLU? It introduces non-linearity, allowing the network to learn complex patterns. Without it, stacking layers would just be matrix multiplication - no better than a single layer!

Step 6: Output

The final output can be passed to the next layer of neurons, or used directly as the network's prediction.

The Full Equation

output = ReLU(x₁×w₁ + x₂×w₂ + x₃×w₃ + bias)

In Python

import numpy as np def neuron(inputs, weights, bias): # Weighted sum z = np.dot(inputs, weights) + bias # ReLU activation return max(0, z)