Neurons are like functions
A neuron simply takes in data, performs a function on it, and outputs a result. It’s just like functions in math or programming!
The power of a single neuron
Let’s use one neuron to perform a function! A great tool for playing with neural networks is TensorFlow Playground. You can find the link here. If you click on it, you’ll see the example I’m about to cover.
![Our neural network with only one neuron.](/img/neurons-are-like-functions/img-2.png)
Our goal is to draw a clear line that separates the orange and blue scatterplot.
The function of the neuron is to take two x-inputs and combine them to calculate a diagonal line that will divide the scatterplot.
Click the play button to see the neuron in action! After several attempts, it will “learn” the values of
x1
andx2
that are needed to draw the dividing line.
![Our function is receiving two x-inputs. The first one draws a vertical line and the second one draws a horizontal line.](/img/neurons-are-like-functions/img-1.png)
Limitations
As we saw, a single neuron can succeed in this simple classification task. However, what if we had a more complex shape to classify?
Several datasets are available in TensorFlow Playground. If you try changing the shape to something else, you’ll see that the neuron will fail. These complex shapes require more lines to be drawn.
![This dataset is too complex for one neuron.](/img/neurons-are-like-functions/img-3.jpg)
Add more neurons!
To properly classify this scatterplot, we need to:
- Add two more neurons (3 total)
- Change the ‘Activation’ field from
linear
totanh
(this topic is for another day)
After some iterations, the three neurons will succeed! You can find the TensorFlow Playground link for this demo here.
Conclusion
Neurons perform mathematical functions and take parameters (x1, x2, x…, x99) to output a result. Having more neurons makes it possible to perform more complex tasks.