This site is under construction.Features and pricing shown here are still being built and may change.
← Back to the parts catalog
Training Zoo · Golden Example · Starter

Forward Pass

Turning input numbers into one prediction

A forward pass is the step where a neural network actually looks at some numbers and produces an answer. It multiplies each input number by a learned "weight" number that says how important that input is, adds up all of those results plus one extra learned number called a bias, and then hands the total to an activation function — a rule like ReLU that decides how much of that total to pass along.

The code

def forward_pass(inputs, weights, bias, activation):
    """One neuron's forward pass: weigh the inputs, add the bias,
    then let the activation function decide what to pass on."""
    total = bias
    for x, w in zip(inputs, weights):
        total += x * w
    return activation(total)


# Example: three inputs feeding one neuron, using the ReLU
# golden example as the activation function.
from_relu_example = forward_pass(
    inputs=[0.5, -1.0, 2.0],
    weights=[0.8, 0.3, -0.5],
    bias=0.1,
    activation=lambda x: max(0.0, x),
)

What each part does

inputs and weights are two lists of the same length. Each input number is multiplied by the weight that matches its position, which is what zip(inputs, weights) lines up for the loop.

bias is one extra learned number added on at the end, giving the neuron a way to shift its answer up or down even when every input is zero.

activation is not one fixed piece of code here — it is handed in as an argument, so this Forward Pass can be plugged into any accepted Activation Function submission, including the ReLU golden example, without this code needing to change at all.

Why this shape

Any accepted submission in this category takes a list of input numbers, a matching list of weights, and one bias number, and returns a single number by calling whichever activation function it is given. Taking the activation function as an argument, instead of hard-coding one, is exactly what lets separately built pieces snap together in the Composer later.