Deep Learning

Deep learning is a branch of machine learning that uses neural networks with many layers. These layers learn representations directly from data, making deep learning especially useful for images, language, audio, and multimodal systems.

What is convolution in deep learning?

Convolution is an operation that applies a small learnable filter across an input to detect local patterns. In image based deep learning, the filter moves over small regions of the image and computes a weighted combination of nearby pixel values. Simple example Suppose a 3 × 3 filter is applied to a small 3 × 3 region of an image. The filter multiplies its values with the corresponding image values and adds the results together: That produces one value in the output feature map. The filter then moves to the next position and repeats the same calculation. Why is convolution useful? A convolutional layer has two important properties: Local connectivity: each output depends only on a small nearby region of the input. Weight sharing: the same filter is reused across different positions. This allows a CNN to detect the same pattern wherever it appears in an image while using far fewer parameters than a fully connected layer. Different filters learn different patterns, producing multiple feature maps. For the complete CNN flow, see “How does a CNN work?” . For the architecture itself, see “What is a convolutional neural network (CNN)?” . In short, convolution scans an input with shared learnable filters to detect local patterns and produce feature maps.

What is pooling in a CNN?

Pooling is a downsampling operation used in many Convolutional Neural Networks (CNNs) to reduce the spatial size of feature maps. It summarizes small regions so the network keeps the most useful information while reducing computation. Example: max pooling Suppose a feature map region is: A 2 × 2 max pooling operation keeps the largest value: The pooling window then moves across the feature map and repeats the same operation. Why is pooling used? Pooling can help by: Reducing feature map height and width. Lowering memory and computation requirements. Making later layers less sensitive to small shifts in feature position. Helping the network focus on stronger local responses. Common types Max pooling: keeps the largest value in each region. Average pooling: replaces each region with its average value. Global average pooling: averages each entire feature map into a single value, often near the end of a CNN. Not every modern CNN uses traditional pooling layers; some architectures use strided convolutions for downsampling instead. For the full processing flow, see “How does a CNN work?” . For how feature maps are created, see “What is convolution in deep learning?” . In short, pooling reduces the spatial size of CNN feature maps by summarizing local regions, which can reduce computation while preserving useful information.

What is a recurrent neural network (RNN)?

A Recurrent Neural Network (RNN) is a neural network designed for sequential data, where the order of inputs matters. Unlike a standard feed forward network, an RNN keeps a hidden state that carries information from earlier steps in the sequence. Here, each hidden state depends on both the current input and the previous hidden state. Why are RNNs useful? RNNs are suited to sequences because information from earlier steps can influence later predictions. They have been used for tasks such as: Language modeling Speech processing Time series prediction Sequence classification Main limitation Basic RNNs can struggle with long range dependencies because gradients may become very small or very large during training. This is one reason architectures such as LSTM and GRU were developed. For those variants, see “What is an LSTM network?” and “What is a GRU network?” . In short, an RNN processes sequence data while carrying information from previous steps through a hidden state.

What is the difference between CNNs and RNNs?

CNNs and RNNs are designed for different kinds of structure in data. CNNs are especially good at learning local spatial patterns, while RNNs are designed to process sequences where order matters. CNNs A Convolutional Neural Network (CNN) applies shared filters across local regions of an input. This makes CNNs well suited to data such as: Images Video frames Spatial signals CNNs learn patterns such as edges, textures, shapes, and higher level spatial features. See “What is a convolutional neural network (CNN)?” for the architecture itself. RNNs A Recurrent Neural Network (RNN) processes data step by step while carrying a hidden state from earlier steps. This makes RNNs suitable for sequential data such as: Time series Speech Text sequences Sensor streams See “What is a recurrent neural network (RNN)?” for the core idea. Main differences CNN: focuses primarily on local spatial relationships. RNN: focuses primarily on relationships across sequence steps. CNN: reuses filters across positions. RNN: reuses recurrent parameters across time steps. CNN: can usually process many spatial positions in parallel. RNN: processes sequence dependencies recurrently, which can make training less parallelizable. Which one should you use? The choice depends on the structure of the problem. If spatial patterns are central, a CNN may be appropriate. If ordered sequence dependencies are central, an RNN or one of its variants may be more appropriate. Modern architectures sometimes combine both ideas, and Transformers have replaced RNNs in many sequence modeling tasks. In short, CNNs are built around spatial pattern extraction, while RNNs are built around sequential information and hidden state.

What is an LSTM network?

An LSTM (Long Short Term Memory) network is a type of recurrent neural network designed to remember useful information over longer sequences. Basic RNNs can struggle to preserve information across many time steps. LSTMs address this with a memory cell and a set of gates that control what information is kept, updated, or exposed. How an LSTM works An LSTM mainly uses three gates: Forget gate: decides what old information should be removed from memory. Input gate: decides what new information should be added. Output gate: decides what part of the memory should influence the current output. A simplified flow is: Why are LSTMs useful? Because they can preserve relevant information for longer periods, LSTMs have been used for tasks such as: Time series forecasting Speech recognition Sequence classification Language modeling They are especially useful when earlier information in a sequence needs to influence predictions much later. LSTM vs basic RNN A basic RNN mainly carries a hidden state from one step to the next. An LSTM adds controlled memory through gates, making it better at handling long range dependencies and reducing some of the difficulties caused by vanishing gradients. For the base architecture, see “What is a recurrent neural network (RNN)?” . For the gradient issue, see “What is the vanishing gradient problem?” . In short, an LSTM is a gated recurrent network that manages a memory state so important information can persist across longer sequences.

What is a GRU network?

A GRU (Gated Recurrent Unit) is a type of recurrent neural network designed to handle longer term dependencies in sequence data using gating mechanisms. It is similar to an LSTM, but its internal structure is simpler. How a GRU works A GRU mainly uses two gates: Update gate: controls how much previous information should be kept. Reset gate: controls how much previous information should be ignored when computing new information. A simplified flow is: Unlike an LSTM, a GRU does not maintain a separate cell state. Its memory is carried mainly through the hidden state. Why use a GRU? GRUs can capture longer range sequence dependencies while using fewer parameters than LSTMs. This can make them: Faster to train in some settings. More memory efficient. Easier to use when a simpler recurrent architecture is sufficient. GRUs have been used for tasks such as time series forecasting, speech processing, and sequence modeling. GRU vs LSTM GRU: uses update and reset gates and has no separate cell state. LSTM: uses input, forget, and output gates with a separate memory cell. Neither is universally better; performance depends on the dataset and task. For the related architecture, see “What is an LSTM network?” and “What is a recurrent neural network (RNN)?” . In short, a GRU is a gated recurrent network that manages sequence memory with a simpler structure than an LSTM.

What is an autoencoder?

An autoencoder is a neural network trained to reconstruct its input after first compressing it into a smaller internal representation. It has two main parts: How it works The encoder transforms the input into a compact representation, often called a latent vector or bottleneck . The decoder tries to rebuild the original input from that representation. Training minimizes the difference between: Because the model must reconstruct the input through a constrained representation, it can learn useful structure in the data. Why are autoencoders useful? Autoencoders are commonly used for: Dimensionality reduction Representation learning Denoising Anomaly detection Data compression research For example, a denoising autoencoder can receive a noisy image and learn to reconstruct a cleaner version. Important point An autoencoder is not simply copying the input. Its usefulness comes from the constraints placed on the internal representation, such as a small bottleneck, noise, sparsity, or other regularization. Different variants, such as variational autoencoders (VAEs) , change how the latent representation is learned and can also be used for generative modeling. In short, an autoencoder learns to encode data into a useful internal representation and decode that representation back into a reconstruction of the original input.

What is transfer learning?

Transfer learning is the practice of starting with a model that has already learned useful patterns from one task or dataset and adapting it to a new, related task. Instead of training a model completely from scratch, you reuse previously learned parameters. Why is transfer learning useful? Training large deep learning models from scratch can require a lot of data and computation. A pretrained model may already contain useful representations, such as visual features in an image model. This can help when: Your new dataset is relatively small. Training from scratch would be expensive. The source and target tasks share useful patterns. Common approaches Feature extraction: keep most pretrained layers fixed and train only a new output layer or small task specific head. Fine tuning: start from pretrained weights and continue training some or all of the model on the new dataset. For example, an image model pretrained on a large image dataset can be adapted to classify plant diseases using a much smaller domain specific dataset. Important limitation Transfer learning works best when the pretrained model has learned representations that are relevant to the new task. If the source and target domains are very different, the benefit may be smaller. In short, transfer learning reuses knowledge from a pretrained model to learn a new task faster and often with less data than training from scratch.

What is the attention mechanism?

Attention is a mechanism that lets a neural network give different importance to different parts of its input when producing an output. Instead of treating every input element equally, the model learns which elements are most relevant to the current prediction. Core idea Attention commonly works with three representations: Query: what the model is currently looking for. Key: what each input element offers for comparison. Value: the information carried by each input element. The query is compared with the keys to produce attention scores. Those scores are converted into weights, and the values are combined using those weights. Simple example In a sentence, when processing one word, attention can assign higher weight to earlier words that are more relevant to its meaning. This allows the model to capture relationships between elements even when they are far apart in the sequence. Why is attention useful? Attention helps models: Focus on the most relevant information. Model long range relationships. Process relationships between many input positions directly. When the queries, keys, and values come from the same sequence, the mechanism is called self attention . Self attention is a central building block of Transformer models. See “What is a Transformer neural network?” for the architecture level explanation. In short, attention learns how strongly different input elements should influence the current representation or prediction.

What is the difference between supervised, unsupervised, and self-supervised deep learning?

The difference is mainly where the learning signal comes from . Supervised deep learning The model learns from labeled examples . Example: The model compares its prediction with the provided target and updates its parameters to reduce the error. Typical uses include classification and regression. Unsupervised deep learning The model learns from unlabeled data without being given the correct output for each example. Its goal is usually to discover useful structure or representations in the data. Examples include: Clustering oriented representation learning Dimensionality reduction Some forms of anomaly detection Autoencoders See “What is an autoencoder?” for one example. Self supervised deep learning Self supervised learning also uses data without manually supplied labels, but it creates a training target from the data itself . For example, a model may be trained to predict: A masked part of an input The next element in a sequence Whether two transformed examples came from the same original sample This allows models to learn useful representations from very large unlabeled datasets. Main distinction Supervised: targets are provided externally. Unsupervised: no explicit target is provided. Self supervised: targets are generated automatically from the input data. Self supervised learning is widely used for pretraining models before adapting them to downstream tasks. In short, supervised learning uses human provided labels, unsupervised learning discovers structure without explicit targets, and self supervised learning creates its own training targets from unlabeled data.