concept

Artificial neurons

An artificial neuron applies an affine map and optional activation; align feature and weight lengths.

Formal Syntax & Structure

artificial-intelligence syntaxartificial-intelligence
z = sum(w_i * x_i) + b; a = max(0, z)

Working Example

Example Snippetartificial-intelligence
def weighted_sum(inputs, weights, bias):    if not inputs or len(inputs) != len(weights):        raise ValueError("Expected equally sized nonempty vectors")    return sum(x * w for x, w in zip(inputs, weights)) + bias
print(weighted_sum([2, 3], [1, -1], 2))print(weighted_sum([2, 5], [1, -1], 2))