Perceptron Lab

One neuron that learns from examples. Frank Rosenblatt, 1958.

Examples

The picture

Click or drag to paint. 1 = black, 0 = white.


        

Its points

one per square

Blue = adds points, orange = takes away. Click a square +1, shift-click −1.


        
OFF

The right answer:

Examples it learned from

Starting Python…

predict(picture, points)

Looks at a picture and answers True (YES) or False (NO).

The neuron uses this code.

Try: total > 5 · add print(total) · count the white squares too. Then press ▶ (or Ctrl+Enter).

train(picture, answer, points)

Learns from one example. If its guess was wrong, it changes the points.

The neuron uses this code.

Try: change = 2 · delete the two lines if guess == answer: and return. Then press ▶.