What Is Deep Learning? From Data to Predictions
From the publisher’s feed, collected in the ZeroLabs newsroom.
What Is Deep Learning? From Data to PredictionsHow does a computer learn to recognize a cat?Nobody sits down and writes thousands of rules like this:“If the image has two ears, four legs, whiskers, and fur, then it is probably a cat.”Rules like that fall apart almost immediately. Some cats have no visible whiskers in the photo. Some dogs have pointy ears. Some pictures are blurry, dark, or taken from strange angles. Every exception needs another rule, and the list never ends.So we do something different. We hand the computer examples: thousands of images, some of cats and some not. The system studies them, looks for patterns, makes a prediction, measures how wrong that prediction was, and quietly adjusts itself so it is a little less wrong next time.That loop is the heart of Deep Learning. This article walks through it from the ground up, with no prior background assumed, so that by the end you have the complete big picture.What you will take away from this article• What Deep Learning is, and how it relates to AI and Machine Learning• What a neural network is made of: layers, neurons, weights, and bias• How a network turns an input into a prediction• How a loss function measures mistakes, and how training uses that signal• What epochs, parameters, and hyperparameters mean• Why depth matters: how layers learn increasingly useful representationsWhat Is Deep Learning?Deep Learning is a branch of Machine Learning, and a good way to think about it is as a mathematical framework for learning representations from data.Machine Learning lets a computer learn patterns from data instead of being programmed for every possible situation. Deep Learning goes a step further. It maps inputs to targets through a deep sequence of simple data transformations, which we call layers. Each layer does something modest on its own. Stacked together, they can capture patterns that would be almost impossible to write by hand.You will often hear three terms used almost interchangeably, so it helps to see how they fit together.Figure 1: Artificial Intelligence contains Machine Learning, which contains Deep Learning.Artificial Intelligence is the broadest idea. Machine Learning is one way of getting there. Deep Learning is a specific approach inside Machine Learning, built on neural networks with multiple layers.Here is a concrete example. Say we want a system to recognize handwritten digits. We show it thousands of labelled examples:Image → 7Image → 3Image → 9Image → 1The network is not memorizing these answers. What it does is adjust a set of internal numbers, called parameters, so that its predictions gradually get better. Once those numbers are tuned, it can handle digits it has never seen before.Where you already meet Deep LearningThe same basic idea shows up in many everyday places:• Recognizing objects and patterns in images• Digital assistants that understand speech• Natural language processing, such as translation and chatbots• Autonomous driving• Transcribing handwriting into textThese look like very different problems. Underneath, they all follow the loop we are about to unpack.What Is a Neural Network?A neural network is a mathematical model made of many small, connected units called neurons, arranged in layers.Figure 2: A basic neural network with an input layer, two hidden layers, and an output layer.Every network has three kinds of layers:• Input layer: receives the raw data• Hidden layers: transform that data step by step• Output layer: produces the final predictionThe word “deep” in Deep Learning comes largely from having many of these layers. The data does not go through one big transformation. It goes through a long chain of simple ones, and each layer builds on what the previous layer produced.One thing worth keeping in mind from the start: neural networks only work with numbers. A photo becomes a grid of pixel values. A sentence becomes numerical representations of words. Whatever the original data looks like, it is turned into numbers before the network ever sees it.What Does a Neuron Actually Do?Zoom in on a single neuron, because everything else in the network is built from it.A neuron receives some inputs. Each input is multiplied by a weight, and the results are added together. Then a bias is added on top. That is the entire job: numbers go in, a small calculation happens, a number comes out.Figure 3: A neuron multiplies each input by a weight, sums the results, and adds a bias.As an equation, that calculation looks like this:Here, x is an input, w is a weight, b is the bias, and z is the resulting weighted sum. In the next article we will see that z is then passed through something called an activation function. For now, the important point is simple: a neuron is just a small mathematical transformation.Weights and Bias: Where the Learning LivesWhy do we need weights at all? Because not every input matters equally.Imagine a model trying to predict whether a student will pass an exam. It might receive:Hours studiedAttendancePrevious scoresAssignments completedSome of these could be much more useful than others, and the weights capture that. A model might end up with something like this:Hours studied → weight = 0.8Attendance → weight = 0.4Previous score → weight = 0.7Assignments → weight = 0.3These numbers are only illustrative. The interesting part is that the network does not start out knowing which inputs matter. It has to learn the weights.The bias is one more adjustable number. It gives the neuron extra flexibility, so its output does not have to depend purely on the weighted inputs.Weights and biases together are the parameters of the network, and that leads to one of the most important ideas in the whole field:Learning means adjusting parameters so that the model produces better predictions.Parameters and hyperparametersTwo terms come up constantly, and they are easy to mix up. Parameters are the values the network learns from data. Hyperparameters are the settings you choose before training starts, which control how the learning happens.ParametersHyperparametersWho sets them?The network learns them during trainingYou choose them before trainingExamplesWeights and biasesNumber of layers and neurons, learning rate, batch size, number of epochsRoleStore what the model has learnedShape how the model trainsFrom Input to PredictionTime to make this concrete with the smallest example we can think of.Suppose our model receives one input, x = 2, and starts with a weight w = 0.5 and a bias b = 0. The neuron calculates:In Python, that is just:x = 2w = 0.5b = 0y_pred = w * x + bprint(y_pred)Output:1.0The code multiplies the input by the weight, adds the bias, and stores the result as the model’s prediction. Nothing more.Obviously, this is not a deep neural network. But it shows the basic operation that real networks repeat over and over, across many neurons and many layers.Figure 4: From input to prediction with a single neuron.But How Does It Learn?Now for the interesting part.Imagine that the correct answer for our input was actually 5, but our model predicted 1. The model is wrong. And it cannot improve unless it knows how wrong it is.That is the job of a loss function. It compares the prediction with the true answer and turns the gap into a single number. A bigger error gives a bigger loss. A smaller error gives a smaller loss.Figure 5: The loss turns the gap between prediction and truth into one number.One common way to do this is to square the gap. With a target of 5 and a prediction of 1:If the model later improved to a prediction of 4, the loss would fall to (5 − 4)² = 1. The exact formula is not the point yet. What matters is that a bad prediction produces a big number, a good one produces a small number, and the model now has something specific to reduce.Notice what this gives the model. It is not simply told, “This answer is wrong.” It receives a numerical score that says how wrong. So training can be summed up as one goal: make the loss smaller.The Training LoopNow we can connect the pieces. Training a neural network is a cycle that repeats many, many times:1. Give it data. The network receives an input, X.2. Make a prediction. The input flows through the layers, which are controlled by the weights, and produces a prediction.3. Calculate the loss. A loss function compares the prediction with the true target, Y, and produces a loss score.4. Work out how to change the parameters. The network calculates gradients, which show how each parameter affects the loss.5. Update the weights. An optimizer adjusts the weights so the loss should go down.6. Repeat. The whole thing happens again with more examples.Figure 6: The training loop. The optimizer uses the loss score to update the weights.Steps 4 and 5 are where backpropagation and optimizers come in. Backpropagation works out how each weight contributed to the error, and the optimizer uses that information to update the weights. We will cover both properly later in this series. For now, just know that this machinery exists, and that it is what turns a loss score into better weights.Repeat the cycle enough times, and the weights settle into values that keep the loss low.What Are Epochs?When the model has seen the entire training dataset once, that is called one epoch.Suppose we have 10,000 training examples. After the network has processed all 10,000, we say “Epoch 1 is complete.” Then it goes through them again for Epoch 2, and again for Epoch 3.Each pass gives the model another chance to reduce its loss. But more epochs are not automatically better. If the model trains for too long, it can start fitting the training data too closely and lose its ability to handle new examples. This problem is called overfitting, and it deserves its own discussion later in the series.Deep Learning Is Really About RepresentationHere is one of the most powerful ideas in Deep Learning. The network does not only make predictions. Along the way, it learns useful representations of the data.Take an image. At the input, the network sees nothing but numbers representing pixels. But as the data moves through the layers, the network can learn increasingly meaningful patterns.Figure 7: Simple patterns combine into more complex ones as data moves through the layers.Early layers tend to pick up simple patterns like edges. Later layers combine those into shapes, then parts, then whole objects. By the time we reach the output, the network is working with something far more useful than raw pixels.The exact representations a real network learns are more complicated than this tidy picture. Still, the progression is a helpful intuition, and it explains why depth matters. Multiple layers let the model transform information again and again, building complexity one step at a time.Deep Learning Is Not MagicIt is easy to look at modern AI systems and assume the model somehow understands everything. A few clarifications help keep the picture honest:• The network is not memorizing answers. It is adjusting parameters so its predictions improve.• “Deep” means many layers. It describes the architecture, not how profound the model is.• More training is not always better. Too many epochs can lead to overfitting.• Underneath, it is arithmetic. Numbers, weights, and mathematical operations, repeated at enormous scale.Strip away the scale, and the process is always the same simple loop:Numbers → Weights → Mathematical operations → Prediction→ Loss → Gradients → Updated weightsThe complexity comes from running this loop across huge datasets, with enormous numbers of parameters. The core idea stays small enough to fit in your head.The Mental Model to KeepIf you only remember one thing from this article, make it this:Deep Learning is a process of learning useful patterns by repeatedly making predictions, measuring errors, and adjusting the model’s parameters.Or, in a slightly longer form:• Data goes into a neural network.• Neurons perform mathematical operations.• Weights decide how inputs influence outputs.• The network produces a prediction.• A loss function measures the error.• Training adjusts the weights.• Repeating this process lets the network learn useful patterns.Quick CheckTry answering these before reading the answers underneath.1. What is the difference between a parameter and a hyperparameter?Parameters, such as weights and biases, are learned during training. Hyperparameters, such as the learning rate or number of epochs, are chosen before training.2. Why does a model need a loss function?It converts the gap between prediction and truth into a number, which gives training a clear quantity to reduce.3. What is an epoch?One complete pass through the entire training dataset.What Comes NextWe have built the big picture, but we skipped over an important detail.What exactly happens inside a neuron?We said a neuron computes a weighted sum. But if that were the whole story, stacking layers would get us very little. So why can’t we simply use the weighted sum as the output?That question leads us to activation functions. In Part 2, we will go inside the neural network and look at neurons, activation functions, and loss functions from the ground up. After that, we will look at how a network actually changes its weights, and then move on to architectures such as CNNs, RNNs, LSTMs, GANs, and autoencoders.What Is Deep Learning? From Data to Predictions was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.