Skip to content
    Neuron City

    DEEP LEARNING · 11 MIN

    Neural Networks & Backpropagation

    Layers of neurons learn by passing errors backwards and nudging every weight.

    PIXEL explains

    • Forward pass: inputs flow through layers to a prediction.
    • Loss measures the error; backpropagation uses the chain rule to find each weight's share of it.
    • CNNs specialise in images, RNNs/Transformers in sequences like text.

    Real world: Photo apps recognising faces, or translation apps turning Hindi into English.

    Code

    import math
    sig = lambda z: 1 / (1 + math.exp(-z))
    w, b, x, y = 0.0, 0.0, 1.0, 1.0
    for _ in range(200):
        p = sig(w * x + b)
        grad = (p - y)  # dLoss/dz for log-loss
        w, b = w - 0.5 * grad * x, b - 0.5 * grad
    print(round(sig(w * x + b), 2))
    Output ›
    0.99
    Try it in the online compiler →

    Checkpoint quiz

    Backpropagation computes…