DEV Community

Audrine Marion
Audrine Marion

Posted on

Neural Networks: Inspired by the Brain, Built for Data

When I first started learning about neural networks, I found the idea both fascinating and slightly intimidating.

The phrase “neural network” makes it sound like something extremely complex, and honestly, once you start looking at layers, weights, activation functions, forward propagation, backpropagation, and optimization, it can become overwhelming pretty quickly.

But beneath all of that mathematics and code is a surprisingly simple idea:

A neural network learns patterns from data by adjusting itself based on its mistakes.

That idea is what made neural networks interesting to me.

As I continue exploring data science and machine learning, understanding neural networks has helped me see machine learning from a different perspective. Instead of simply telling a computer what rules to follow, we can give it data and allow it to learn patterns that may be difficult for us to define manually.

In this article, I'll break down where the inspiration for neural networks came from, what they are, and the major components that make them work.


Where Did Neural Networks Come From?

The inspiration behind artificial neural networks comes from something we already have:

the human brain.

Our brains contain billions of neurons that communicate with one another. A biological neuron receives signals, processes them, and passes a signal forward when certain conditions are met.

Artificial neural networks don't replicate the human brain perfectly. Instead, they borrow a simplified idea from how biological neurons work.

A biological neuron can be thought of roughly as:

receive signals → process them → produce a response

An artificial neuron follows a similar conceptual process:

receive inputs → calculate a weighted sum → apply an activation function → produce an output

This was one of the things I found interesting when learning about neural networks.

The goal isn't to recreate the brain inside a computer.

The goal is to take a useful idea from biology and turn it into a mathematical model that can learn from data.


So, What Exactly Is a Neural Network?

A neural network is a machine learning model made up of interconnected nodes, commonly called neurons.

These neurons are organized into layers.

A basic neural network usually contains:

  1. Input layer
  2. One or more hidden layers
  3. Output layer

A simple representation looks like this:

Input Layer        Hidden Layer        Output Layer

   x₁  ─────────►    ○
                    │
   x₂  ─────────►    ○ ─────────►     ŷ
                    │
   x₃  ─────────►    ○
Enter fullscreen mode Exit fullscreen mode

The input layer receives the data.

The hidden layers transform the data and learn patterns.

The output layer produces the final prediction.

The interesting part is that we don't manually program the network to recognize every possible pattern.

Instead, the network learns the parameters needed to recognize those patterns from examples.


1. The Input Layer

Everything starts with the input.

Suppose we want to predict whether a student is likely to pass an exam.

Our dataset might contain:

  • Hours studied
  • Attendance
  • Previous test scores
  • Assignment completion

These become our input features.

For example:

Hours Studied     = 6
Attendance        = 85%
Previous Score    = 72
Assignments       = 9
Enter fullscreen mode Exit fullscreen mode

The neural network receives these values through the input layer.

One important thing I learned is that neural networks generally work best when the input data has been appropriately prepared.

That can involve:

  • Handling missing values
  • Encoding categorical variables
  • Scaling numerical features
  • Removing irrelevant features
  • Splitting data into training and testing sets

So even though neural networks are powerful, data preparation still matters.

Garbage in can still mean garbage out.


2. Neurons

The basic building block of a neural network is the artificial neuron.

A neuron takes several inputs, assigns different importance to them using weights, adds a bias, and then passes the result through an activation function.

Mathematically, we can represent this as:

$$
z = w_1x_1 + w_2x_2 + ... + w_nx_n + b
$$

Where:

  • (x) = input
  • (w) = weight
  • (b) = bias
  • (z) = weighted sum

The neuron then applies an activation function:

$$
a = f(z)
$$

The result becomes the neuron's output.

This might look complicated initially, but the basic idea is straightforward:

The neuron combines information from its inputs and decides how strongly to activate.


3. Weights

Weights determine how important different inputs are to a neuron.

Imagine we're predicting whether a student will pass.

Perhaps hours studied is more predictive than the number of assignments completed.

The network can learn this by assigning different weights to those features.

For example:

Hours studied       → weight = 0.8
Attendance          → weight = 0.5
Previous score      → weight = 0.9
Assignments         → weight = 0.3
Enter fullscreen mode Exit fullscreen mode

These numbers are only examples.

During training, the neural network continuously adjusts its weights to improve its predictions.

This is one of the key ideas behind learning in neural networks.

The model isn't explicitly told what the correct weights are. It learns them from data.


4. Bias

Another component is the bias.

Bias gives the neuron some flexibility in determining when it should activate.

Without going too deep into the mathematics, you can think of the bias as an additional parameter that allows the activation function to shift.

The basic equation becomes:

$$
z = wx + b
$$

The weights control the influence of the inputs, while the bias helps adjust the overall output.

Both weights and biases are learned during training.


5. Activation Functions

This was one of the concepts that really helped me understand why neural networks can learn complex patterns.

After calculating the weighted sum, a neuron applies an activation function.

Why?

Because without activation functions, stacking multiple layers of neurons would still result in a fundamentally linear transformation.

Activation functions introduce non-linearity.

And real-world data is rarely perfectly linear.

Some commonly used activation functions include:

Sigmoid

The sigmoid function produces values between 0 and 1.

$$
\sigma(x) = \frac{1}{1 + e^{-x}}
$$

This makes it useful in certain binary classification problems, particularly as an output activation.

For example:

0.91 → high probability of class 1
0.12 → low probability of class 1
Enter fullscreen mode Exit fullscreen mode

ReLU

ReLU stands for Rectified Linear Unit.

It is defined as:

$$
ReLU(x) = \max(0,x)
$$

So:

x = -3 → 0
x =  2 → 2
x =  7 → 7
Enter fullscreen mode Exit fullscreen mode

ReLU became particularly important in deep learning because it is simple and computationally efficient and helps neural networks model nonlinear relationships.


Softmax

Softmax is commonly used in the output layer for multi-class classification.

Suppose we're classifying an image as:

Cat
Dog
Bird
Enter fullscreen mode Exit fullscreen mode

Softmax can convert the model's outputs into probabilities that sum to 1.

For example:

Cat  → 0.10
Dog  → 0.82
Bird → 0.08
Enter fullscreen mode Exit fullscreen mode

The model would predict Dog.


6. Hidden Layers

Now we get to one of the most important parts of a neural network.

The hidden layers.

These layers sit between the input and output layers.

A network with only a few layers might look like:

Input → Hidden → Output
Enter fullscreen mode Exit fullscreen mode

A deeper network could look like:

Input
  ↓
Hidden Layer 1
  ↓
Hidden Layer 2
  ↓
Hidden Layer 3
  ↓
Hidden Layer 4
  ↓
Output
Enter fullscreen mode Exit fullscreen mode

Each layer can learn different representations of the data.

This is where the term deep learning comes from.

A neural network with many hidden layers is generally described as a deep neural network.

The interesting part is that the network can learn increasingly complex representations as information moves through the layers.

For example, in an image recognition task:

Pixels
  ↓
Edges
  ↓
Shapes
  ↓
Patterns
  ↓
Objects
Enter fullscreen mode Exit fullscreen mode

The network isn't necessarily programmed with these exact rules.

It learns useful representations from the training data.


7. Forward Propagation

So how does a neural network actually make a prediction?

This happens through forward propagation.

The input data moves through the network from the input layer toward the output layer.

At each neuron:

  1. Inputs are multiplied by weights.
  2. The results are added together.
  3. A bias is added.
  4. An activation function is applied.
  5. The result is passed to the next layer.

Eventually, the network produces a prediction.

Conceptually:

Input
  ↓
Weighted Sum
  ↓
Activation
  ↓
Next Layer
  ↓
Weighted Sum
  ↓
Activation
  ↓
Prediction
Enter fullscreen mode Exit fullscreen mode

This happens extremely quickly when implemented computationally.


8. Loss Functions

The network makes a prediction.

But how does it know whether the prediction is good or bad?

This is where the loss function comes in.

A loss function measures the difference between the model's prediction and the actual target.

For example:

Actual value      = 1
Predicted value   = 0.3
Enter fullscreen mode Exit fullscreen mode

There is a significant difference.

The loss function quantifies that error.

Different problems use different loss functions.

Some common examples include:

  • Mean Squared Error (MSE)
  • Binary Cross-Entropy
  • Categorical Cross-Entropy

The general goal during training is simple:

Minimize the loss.


9. Backpropagation

This is probably one of the most important concepts in neural networks.

After making a prediction and calculating the loss, the network needs to figure out:

Which weights contributed to the error, and how should they change?

This is where backpropagation comes in.

The error is propagated backward through the network.

Using calculus—particularly the chain rule—the network calculates gradients that indicate how changes in the parameters would affect the loss.

Conceptually:

Prediction
    ↓
Calculate Loss
    ↓
Propagate Error Backward
    ↓
Calculate Gradients
    ↓
Update Weights
Enter fullscreen mode Exit fullscreen mode

Then the process repeats.

Again.

And again.

And again.

This is how the neural network gradually improves.


10. Optimizers

Backpropagation tells us how the parameters should change.

The optimizer determines how those changes are actually made.

One of the most well-known optimization algorithms is Gradient Descent.

The basic idea is to move the model's parameters in a direction that reduces the loss.

A simplified update rule looks like:

$$
w_{new} = w_{old} - \eta \frac{\partial L}{\partial w}
$$

Where:

  • (w) = weight
  • (\eta) = learning rate
  • (L) = loss

The learning rate controls how large each update should be.

If the learning rate is too large, the model may overshoot useful solutions.

If it is too small, training may take a very long time.

Other optimizers include:

  • Adam
  • RMSprop
  • Adagrad
  • SGD with momentum

Adam is particularly common in practical deep learning applications.


11. Epochs and Batches

Neural networks don't normally learn from the entire dataset in a single step.

Instead, training data is often divided into smaller groups called batches.

For example, if we have:

10,000 training samples
Enter fullscreen mode Exit fullscreen mode

we might use:

Batch size = 32
Enter fullscreen mode Exit fullscreen mode

The network processes 32 samples at a time.

Once it has processed the entire training dataset, we have completed one epoch.

So:

Dataset
   ↓
Batch 1
Batch 2
Batch 3
...
Batch N
   ↓
One Epoch
Enter fullscreen mode Exit fullscreen mode

The model typically trains for multiple epochs.


12. Learning Rate

The learning rate determines how aggressively the model updates its parameters.

Think of it as the size of the steps the model takes while trying to minimize its loss.

A very large learning rate might look like:

Too large
    ↓
Overshoot
    ↓
Unstable training
Enter fullscreen mode Exit fullscreen mode

A very small learning rate might look like:

Too small
    ↓
Tiny updates
    ↓
Very slow learning
Enter fullscreen mode Exit fullscreen mode

Finding an appropriate learning rate can make a significant difference in training performance.


13. Training, Validation, and Testing

Another important concept is understanding how we evaluate a neural network.

We generally don't want to train and evaluate the model on exactly the same data.

Instead, data can be divided into:

Dataset
   │
   ├── Training Data
   │
   ├── Validation Data
   │
   └── Test Data
Enter fullscreen mode Exit fullscreen mode

Training data

Used to learn the model's parameters.

Validation data

Used to monitor performance and help with choices such as hyperparameters and model architecture.

Test data

Used to evaluate how well the final model performs on unseen data.

This is important because a model can perform extremely well on its training data but poorly on new data.

That brings us to one of the biggest challenges in machine learning.


14. Overfitting

A neural network can become too good at memorizing the training data.

This is known as overfitting.

Imagine studying for an exam by memorizing the answers to last year's exact questions.

You might perform extremely well if the same questions appear.

But if the questions change, your performance may drop.

A similar thing can happen with machine learning models.

The model learns the training examples extremely well but fails to generalize to unseen data.

Some techniques used to reduce overfitting include:

  • Dropout
  • Regularization
  • Early stopping
  • Data augmentation
  • More training data
  • Simpler model architectures

Why Are Neural Networks So Powerful?

What makes neural networks particularly interesting is their ability to learn nonlinear relationships and complex representations.

Traditional programming often looks like:

Rules + Data → Output
Enter fullscreen mode Exit fullscreen mode

Machine learning changes the approach:

Data + Expected Outputs → Learned Rules
Enter fullscreen mode Exit fullscreen mode

And neural networks take this further by learning multiple levels of representation.

This is why they have become so useful in areas such as:

  • Computer vision
  • Natural language processing
  • Speech recognition
  • Recommendation systems
  • Time-series forecasting
  • Fraud detection
  • Medical imaging
  • Generative AI

From Neural Networks to Deep Learning

A neural network with many layers is generally referred to as a deep neural network.

Deep learning is essentially about using these deeper architectures to learn increasingly complex representations from data.

This has led to architectures designed for different kinds of problems.

For example:

Convolutional Neural Networks (CNNs)

Often associated with image and computer vision tasks.

Recurrent Neural Networks (RNNs)

Designed to work with sequential data, although many modern sequence tasks now use transformer-based architectures instead.

Transformers

Transformers have become extremely important in modern AI, particularly for language and other sequence-based problems.

They power many of the systems behind today's generative AI applications.


What I Take Away From Learning Neural Networks

One thing I appreciate about neural networks is that they changed how I think about machine learning.

At first, the equations can make the subject feel intimidating.

You see:

$$
z = wx+b
$$

then activation functions, gradients, derivatives, optimization algorithms, layers, epochs, and suddenly it feels like you're drowning in mathematics.

But when you break the process down, the basic idea becomes much easier to understand.

A neural network:

takes data → makes a prediction → measures its error → adjusts itself → tries again.

That cycle is at the heart of learning.

And I think that's the part that makes neural networks so fascinating.


Final Thoughts

I'm still learning neural networks, and I don't think understanding them means memorizing every equation or being able to build a state-of-the-art architecture from scratch.

For me, understanding the fundamentals is more important.

I want to know:

  • What is happening to the data?
  • Why do we need weights?
  • What does a bias actually do?
  • Why do we need activation functions?
  • How does the model know that it made a mistake?
  • How does backpropagation help?
  • What does an optimizer actually change?
  • How do we know whether the model is learning or simply memorizing?

Once these pieces start fitting together, neural networks stop looking like a mysterious black box.

They become a collection of understandable ideas working together.

And that's probably the most important lesson I've taken from studying them so far:

Complex models become much less intimidating when you understand the simple ideas underneath them.

I'm still on that learning journey and neural networks are definitely one of the areas I'm excited to explore more deeply.

Top comments (0)