The perceptron
Not met yet
A perceptron multiplies each reading by a weight, adds them up and adds a bias. If the total is above 0 it says 1, otherwise 0. It learns one example at a time: when it is right nothing changes, and when it is wrong every weight moves by rate * error * reading, where error = label - guess. It draws one straight line, so it can learn any rule a straight line can split, and no other.
Try it
main.pyimport numpy as np weights = np.array([-0.4, -0.2, -0.1]) # cloud, humidity, moon bias = 0.3 night = np.array([0.1, 0.5, 0.2]) total = np.dot(weights, night) + bias print(1 if total > 0 else 0)
Output
Press Run and what your program prints shows up here.
Easy to get wrong
- Thinks a neuron starts out knowing which readings should count against a yes, before it has learned anything.
- Thinks a weighted sum of exactly 0 counts as above the threshold, so the perceptron says 1.
- Thinks a perceptron's weights change after every example, even the ones it got right.
- Thinks one perceptron can learn any yes-or-no rule, given enough epochs.
- Thinks that on a rule it cannot learn, the perceptron settles on the best straight line and gets nearly everything right.