WeCodeAcademy

A Single Artificial Neuron

The building block of a neural network is the neuron. It multiplies each input by a weight, adds them up with a bias, and fires (outputs 1) if the total passes zero. The weights and bias are what the network learns.

Here a neuron with hand-picked weights behaves like the logical AND gate: it fires only when both inputs are 1.

Examplepython
Open in editor »
Quick check

What are the weights and bias for?

Your turn: write the code

Change the bias so the neuron behaves like an OR gate (fires when either input is 1) and print its output for inputs 1 and 0.

Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.

Tip: use the left and right arrow keys to move between lessons.