AI: an artificial neuron
An artificial neuron receives inputs, multiplies each one by a weight, adds everything up with a bias, then applies an activation function: here, it answers 1 if the total is positive, otherwise 0. The neural networks behind modern AI stack millions of these small calculations.
"Training" a neuron means finding the weights and bias that give the right answers. With weights [1, 1] and a bias of −1.5, the neuron only fires when both inputs are 1: it reproduces logical AND. Changing only the bias gives a different behaviour.
def neuron(inputs, weights, bias):
total = sum(x * w for x, w in zip(inputs, weights)) + bias
return 1 if total > 0 else 0
# A neuron that behaves like "AND"
weights, bias = [1, 1], -1.5
for a in (0, 1):
for b in (0, 1):
print(a, b, "->", neuron([a, b], weights, bias))