AI Foundations for Developers COURSE·LESSON 11 OF 410 completed

Neurons, Layers, and Activation Functions

A neuron is a weighted calculation

A simple artificial neuron computes z = dot(weights, inputs) + bias, then applies an activation function. The weights decide which input combinations matter; the activation changes how that score is passed onward.

ReLU returns max(0,z). Sigmoid maps a score to (0,1). GELU, used in many transformer variants, smoothly gates inputs. The right activation depends on architecture and purpose. A bounded activation is not automatically a probability model unless training and interpretation support that use.

Why multiple nonlinear layers help

Stacking linear layers without nonlinearities collapses into another linear transformation. Nonlinearities let networks represent more complex relationships.

Consider two features: payment failed and retry succeeded. “Needs intervention” might depend on their combination rather than either alone. Hidden layers can learn useful intermediate representations instead of requiring every combination to be designed manually.

python
def relu(x):
    return max(0.0, x)

x = [2.0, -1.0]
weights = [[1.0, 1.0], [-1.0, 2.0]]
bias = [0.0, 1.0]
hidden = [relu(sum(a*b for a, b in zip(row, x)) + b)
          for row, b in zip(weights, bias)]
score = hidden[0] * 3 + hidden[1] * -2
print(hidden, score)  # [1.0, 0.0] 3.0

This is a hand-configured network. No learning occurs until an optimizer changes the weights. Trace it in the Python compiler.

Rendering diagram…
flowchart LR
  A[Input features] --> B[Weighted sums]
  B --> C[Nonlinear activations]
  C --> D[Next learned layer]
  D --> E[Task output and loss]

Architecture terms developers encounter

An MLP is a feed-forward stack of layers. CNNs use local filters and weight sharing, useful for spatial patterns. RNNs process sequences using recurrent state; LSTMs add gates to manage information over time. Transformers use attention and feed-forward transformations, with sequence position represented explicitly. Different tasks still benefit from different architectures.

Model capacity describes what it can represent, not what it actually learned. More layers or parameters do not automatically overcome poor labels or an unsuitable objective.

Checkpoint with answers

Why do activations matter? They prevent a stack from reducing to one linear map and allow richer functions.

Does the example contain training? No; it performs a forward pass with fixed weights.

What happens when ReLU receives -3? It outputs 0. For a negative input its usual derivative is 0, which can affect gradient flow.

Learn at your own pace0 / 41 lessons complete