Skip to content

    Perceptron

    AI · Beginner

    Definition

    A perceptron is the simplest neuron: weighted sum plus bias passed through a step function.

    The building block that led to modern neural networks.

    Diagram

    x1·w1 + x2·w2 + b→ step→ 0/1

    Flowchart

    Multiply inputs by weightsAdd biasApply stepUpdate weights on mistakes

    Example: AND gate

    w, b = [1, 1], -1.5
    for x in [(0,0), (0,1), (1,0), (1,1)]:
        print(int(w[0]*x[0] + w[1]*x[1] + b > 0), end=' ')

    Output: 0 0 0 1

    Key points

    • Only learns linearly separable data
    • Cannot learn XOR alone

    Interview questions

    Why can't it learn XOR?

    XOR is not linearly separable; you need a hidden layer.

    More AI topics