concept

Layers and forward pass

A dense forward pass maps input coordinates to output coordinates with one weight row per output unit.

Formal Syntax & Structure

artificial-intelligence syntaxartificial-intelligence
z = W x + b; h = ReLU(z)

Working Example

Example Snippetartificial-intelligence
def dense(inputs, weights, biases):    if not inputs or not weights or len(weights) != len(biases):        raise ValueError("Invalid layer dimensions")    if any(len(row) != len(inputs) for row in weights):        raise ValueError("Each weight row needs one value per input")    return [sum(w * x for w, x in zip(row, inputs)) + b            for row, b in zip(weights, biases)]
def forward(inputs):    z = dense(inputs, [[1, -1], [1, 1]], [2, -1])    hidden = [max(0, v) for v in z]    output = dense(hidden, [[2, -1]], [1])    return z, hidden, output
print(forward([2, 3]))print(forward([0, 3]))