ViewWiki

Lesson 2 of 4

Neurons and weights.

About 20 minutes · 5 practice questions

What an artificial neuron computes: a weighted sum plus a bias, a sigmoid that turns it into a value between 0 and 1, a network of layers, and how many weights and parameters it holds.

Step 1 of 5 · A neuron

Step 1 of 5

A neuron

A line is a model of one input. When there are several inputs, such as the two numbers that place a point, you use a neuron: a small unit that multiplies each input by a weight, adds them up, and adds a bias:

z=w1x1+w2x2+bz = w_1 x_1 + w_2 x_2 + b⁠

A large weight means the input matters; a negative weight, that it argues against. The name comes from the nerve cells of the brain, which sum signals from other cells, but the artificial neuron is just this sum.

To the question

Step 2 of 5

Activation

After the sum, the neuron passes zz⁠ through an activation function. The output neuron of the network in the Scene uses the sigmoid,

σ(z)=11+e−z\sigma(z) = \frac{1}{1 + e^{-z}}⁠

which turns any number into a value between 00⁠ and 11⁠: a large negative zz⁠ gives nearly 00⁠, z=0z = 0⁠ gives a half, and a large positive zz⁠ nearly 11⁠. The hidden neurons use a similar function that gives a value between −1-1⁠ and 11⁠.

To the question

Step 3 of 5

Layers

One neuron can only split the plane with a straight line. To learn complicated shapes, neurons are arranged in layers: the input layer, hidden layers, and an output layer, with each neuron joined to every neuron in the next layer. The network in the Scene takes the position of a point, (x,y)(x, y)⁠, and decides whether it is blue or orange.

To the question

Step 4 of 5

Parameters

The weights and biases are the network’s parameters, like the aa⁠ and bb⁠ of the line. They are everything the network “knows”; the structure alone knows nothing.

To the question

Interactive scene

Loading the interactive version…

Each step sets up the Scene for you, and a control marked “fixed” stays put for that step.

To the experiment

Practice · Calculate

A neuron has two inputs, x1=0.5x_1 = 0.5⁠ and x2=−1x_2 = -1⁠, with weights w1=2w_1 = 2⁠ and w2=0.5w_2 = 0.5⁠, and its bias is b=0.3b = 0.3⁠. What is the weighted sum z=w1x1+w2x2+bz = w_1 x_1 + w_2 x_2 + b⁠?

To the experiment

Practice · Choose

The neuron passes z=0.8z = 0.8⁠ through the sigmoid, σ(z)=11+e−z\sigma(z) = \dfrac{1}{1 + e^{-z}}⁠, which turns any number into a value between 00⁠ and 11⁠. What comes out?

To the experiment

Practice · Calculate

The Scene’s network has 22⁠ input neurons, two hidden layers of 55⁠, and one output neuron, and each neuron is joined to every neuron in the next layer. Each link has one weight. How many weights does the network have?

To the experiment

Practice · Calculate

Every neuron except the inputs also has a bias. How many parameters, weights and biases together, does training have to tune?