The Artificial Neuron: Building the Foundation of Neural Networks

Introduction

Welcome to the second lesson in our course "Neural Network Fundamentals: Neurons and Layers"! Now that you've been introduced to the basics of neural networks, we're ready to dive deeper into their core components. In this lesson, we'll focus on the fundamental building block of neural networks: the artificial neuron. You'll learn what a neuron is, how it processes information, and implement a simple artificial neuron in Python.

By the end of this lesson, you'll understand how an artificial neuron works, both conceptually and mathematically, and you'll have hands-on experience coding one from scratch using only NumPy. This practical, code-focused approach will give you a much deeper understanding of neural networks than simply using existing libraries.

Recap: Biological Inspiration

Before diving into code, let's recap where the concept of an artificial neuron comes from. Artificial neurons are inspired by the biological neurons in our brains.

In your brain, a biological neuron receives signals from other neurons through structures called dendrites. These signals are processed in the cell body, and if the combined signal is strong enough, the neuron "fires," sending a signal through its axon to other neurons.

An artificial neuron mimics this behavior in a simplified way:

  • Inputs represent the signals received from other neurons (like dendrites);
  • Weights represent the strength of each connection;
  • Bias represents the neuron's tendency to fire regardless of inputs;
  • Activation function (which we'll cover in future lessons) mimics the "firing" behavior.

This simple model, when combined with many other neurons, forms the basis of neural networks that can learn complex patterns and make predictions. The beauty of this approach is that even though individual neurons perform very simple operations, their collective behavior can solve incredibly complex problems — from recognizing faces to translating languages.

The Mathematical Model of a Neuron

Let's formalize the mathematical model of an artificial neuron. A neuron takes multiple inputs, multiplies each by a corresponding weight, sums these weighted inputs, adds a bias, and produces an output.

Mathematically, for a neuron with nn inputs (x1,x2,…,xnx_1, x_2, \ldots, x_n), we calculate the output as:

output=(w1×x1)+(w2×x2)+…+(wn×xn)+b\text{output} = (w_1 \times x_1) + (w_2 \times x_2) + \ldots + (w_n \times x_n) + b

Where:

  • x1,x2,…,xnx_1, x_2, \ldots, x_n are the input values
  • w1,w2,…,wnw_1, w_2, \ldots, w_n are the weights for each input
  • bb is the bias

This calculation is also known as a weighted sum plus bias. We can express this more concisely using vector notation:

output=wâ‹…x+b\text{output} = \mathbf{w} \cdot \mathbf{x} + b

Where w⋅x\mathbf{w} \cdot \mathbf{x} represents the dot product of the weight vector and the input vector. This compact notation highlights why tools like NumPy are so useful — they're optimized for these vector operations that are central to neural network calculations.

Think of the weights as importance factors — they determine how much attention the neuron pays to each input. The bias acts like a threshold adjustment that makes it easier or harder for the neuron to produce a high output regardless of the inputs.

Sign up

Join the 1M+ learners on CodeSignal

Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal