
Deep Learning Models: Main Types and When to Use Each
The main deep learning models are convolutional neural networks (CNNs) for images, recurrent networks such as LSTMs for sequences like text or time series, and autoencoders for compressing and cleaning data. Pick the model whose design matches the shape of your data. This lesson, the last in our Deep Learning with Keras series, explains each type in plain language, with short Keras examples.
What makes a model “deep” in the first place?
A neural network with a single hidden layer is usually called shallow. Add many hidden layers, often with many neurons each, and you have a deep neural network. The extra layers matter because each one can build on what the previous one found. Early layers pick up simple patterns, and later layers combine them into richer ideas.
There is a second difference that matters even more in practice. Shallow networks generally expect tidy, hand-prepared inputs, such as a row of numbers describing a house. Deep networks can work with raw material like pixels or words and learn which features are useful on their own. That is a big reason deep learning models took over so many tasks.
Why did this take off when it did? Three things came together: better research ideas, far more available data, and much stronger computing hardware. None of these alone would have been enough, and all three keep improving, so the tools you can learn on today keep getting better every day.
If you are new to the foundations, the earlier lessons help: start with what neural networks are, then see how the basics fit together and how Keras relates to other libraries.
Convolutional networks: when should you use them?
Use a convolutional neural network when your data is an image, or anything image-like. CNNs are built on the assumption that the input is a grid of pixels, which is why they are the usual choice for image recognition, object detection and other computer vision work.
The analogy: imagine sliding a small magnifying glass across a photo. At each position you ask one question, such as “is there an edge here?” The magnifying glass is a filter, and the answers form a new map showing where that pattern appears. A CNN learns many such filters by itself.
Images arrive in a simple shape: height by width by channels. A grayscale picture has one channel, and a color picture has three (red, green, blue). A CNN is usually made of a few repeating parts:
- Convolutional layer. Applies the filters across the image. It typically uses ReLU, an activation that passes positive values through and turns negative ones into zero.
- Pooling layer. Shrinks the map so the network has less to process. Max pooling keeps the strongest value in each small patch, and average pooling keeps the mean.
- Fully connected layer. After flattening the maps into a long list, every value connects to every neuron in the next layer, which produces the final decision.
Here is an illustrative Keras 3 sketch for small grayscale images and ten classes. It shows the structure and is not a tuned model.
import keras
from keras import layers
# Illustrative only: a tiny CNN for 28x28 grayscale images, 10 classes
model = keras.Sequential([
keras.Input(shape=(28, 28, 1)),
layers.Conv2D(16, kernel_size=3, activation="relu"),
layers.MaxPooling2D(pool_size=2),
layers.Flatten(),
layers.Dense(10, activation="softmax"),
])
model.compile(
optimizer="adam",
loss="sparse_categorical_crossentropy",
metrics=["accuracy"],
)
model.summary()
Read it top to bottom and you can see the three parts above: convolution, pooling, then a flatten step and a dense layer.
Recurrent networks and LSTMs: what about sequences?
Use a recurrent neural network (RNN) when order matters: sentences, music, sensor readings, handwriting, DNA sequences or prices over time. A plain feed-forward network treats every example as an independent item with no memory of what came before. A recurrent network does not. At each step it takes the new input and also its own output from the previous step.
The analogy: reading a sentence. You do not understand the word “it” in isolation, you understand it because of the words you read just before. An RNN carries a running summary forward in the same way.
Basic RNNs struggle to remember things over long stretches. The long short-term memory network (LSTM) is a popular fix. It adds gates that decide what to keep, what to forget and what to pass on, so useful information can survive much longer. LSTMs are used for tasks such as handwriting generation, image captioning and describing video.
Here is an illustrative Keras 3 sketch that reads a sequence of 30 steps with one value each and predicts a single number.
import keras
from keras import layers
# Illustrative only: an LSTM that reads 30 time steps, 1 feature each
model = keras.Sequential([
keras.Input(shape=(30, 1)),
layers.LSTM(32),
layers.Dense(1),
])
model.compile(optimizer="adam", loss="mse")
model.summary()
One honest note: sequence prediction, especially for things like stock prices, is hard. A model that fits past data nicely does not guarantee good future predictions, so be cautious about big claims.
Autoencoders: what are they used for?
An autoencoder learns to compress data and then rebuild it. It has two halves. The encoder squeezes the input into a small summary, and the decoder tries to reconstruct the original from that summary. Both halves are learned from the data, and nobody writes the compression rules by hand. Because of that, an autoencoder is data-specific: one trained on handwritten digits will not compress photos of landscapes well.
The analogy: describing a picture to a friend over the phone in ten words, and your friend sketching it from your description. To do well, you must keep only the details that matter.
Common uses include removing noise from data and reducing the number of dimensions so complex data can be visualized. Here is an illustrative Keras 3 sketch for flattened 28×28 images (784 values) squeezed down to 32.
import keras
from keras import layers
# Illustrative only: compress 784 values to 32, then rebuild them
inputs = keras.Input(shape=(784,))
encoded = layers.Dense(32, activation="relu")(inputs)
decoded = layers.Dense(784, activation="sigmoid")(encoded)
autoencoder = keras.Model(inputs, decoded)
autoencoder.compile(optimizer="adam", loss="mse")
autoencoder.summary()
When you train it, the input and the target are the same data. The model is graded on how closely its rebuilt output matches what it was given.
You may also meet restricted Boltzmann machines, a related older family of models. They have been used to help with imbalanced datasets, to estimate missing values and to extract features automatically.
How do you choose the right model?
Start from your data, not from the fanciest model name.
| Your data | Good starting point | Why |
|---|---|---|
| Images | CNN | Filters look for local patterns anywhere in the picture |
| Text, time series, other ordered data | RNN or LSTM | Remembers earlier steps |
| Data you want to compress, denoise or visualize | Autoencoder | Learns a compact summary |
| A simple table of numbers | A small dense network | Often enough to begin with |
A few practical habits help beginners. Start with the smallest model that could work, get it training end to end, and only then make it bigger. Compare against a very simple baseline so you know whether the extra complexity pays off. And keep a separate set of data for testing, so you measure how the model does on examples it has never seen.
Key takeaways
- A network with one hidden layer is shallow, and one with many hidden layers is deep. Deep networks can learn from raw inputs like pixels and text.
- Deep learning grew quickly thanks to better ideas, more data and stronger hardware.
- CNNs suit images. They use filters, ReLU, pooling and a final fully connected stage.
- RNNs and LSTMs suit ordered data because they carry information from one step to the next.
- Autoencoders learn to compress and rebuild data, which is useful for denoising and visualization.
- Choose the model from the shape of your data, start small, and always test on unseen examples.
FAQ
Do I need a GPU to learn deep learning models?
No. Small examples like the ones above run fine on an ordinary laptop. A GPU becomes helpful when your models or datasets grow larger and training starts to feel slow.
Can one project combine several model types?
Yes. Many real systems mix them. For example, a CNN can read the frames of a video while an LSTM reads the sequence of results. Learn each piece first, then combine them.
What is overfitting, and how do I spot it?
Overfitting means a model memorizes its training data instead of learning general patterns. The usual sign is that accuracy on training data keeps improving while accuracy on separate validation data stalls or gets worse. More data, a smaller model or techniques like dropout can help.
Are restricted Boltzmann machines still worth learning?
They are worth a look for historical and conceptual reasons, but most beginners get more value from CNNs, LSTMs and autoencoders first. Treat them as an optional extra once the basics feel comfortable.
Written by the Tomorroo editorial team
Last updated: 2026-11-09








