ApX logoApX logo
ModelsCalculatorHardwareCoursesPricing
ApX logoApX logo
ModelsCalculatorHardwareCoursesPricing

All Courses

Introduction to Deep Learning
Chapter 1: Neural Network Foundations
From Machine Learning to Deep Learning
Biological Inspiration: The Neuron
The Artificial Neuron: A Mathematical Model
The Perceptron: The Simplest Neural Network
Limitations of Single-Layer Perceptrons
Multi-Layer Perceptrons (MLPs): Adding Depth
Hands-on Practical: Building a Simple Perceptron Model
Quiz for Chapter 1
Chapter 2: Activation Functions and Network Architecture
The Role of Activation Functions
Sigmoid Activation
Hyperbolic Tangent (Tanh) Activation
Rectified Linear Unit (ReLU)
Variants of ReLU (Leaky ReLU, PReLU, ELU)
Choosing the Right Activation Function
Understanding Network Layers: Input, Hidden, Output
Designing Feedforward Network Architectures
Hands-on Practical: Implementing Different Activations
Quiz for Chapter 2
Chapter 3: Training Neural Networks: Loss and Optimization
Measuring Performance: Loss Functions
Common Loss Functions for Regression (MSE, MAE)
Common Loss Functions for Classification (Cross-Entropy)
Optimization: Finding the Best Weights
Gradient Descent Algorithm
Learning Rate
Stochastic Gradient Descent (SGD)
Challenges with Gradient Descent
Hands-on Practical: Visualizing Gradient Descent
Quiz for Chapter 3
Chapter 4: Backpropagation and Advanced Optimization
Calculating Gradients: The Chain Rule
Computational Graphs
The Backpropagation Algorithm Explained
Forward Pass vs. Backward Pass
Gradient Descent with Momentum
RMSprop Optimizer
Adam Optimizer
Choosing an Optimization Algorithm
Hands-on Practical: Backpropagation Step-by-Step
Quiz for Chapter 4
Chapter 5: Building and Training Deep Neural Networks
Introduction to Deep Learning Frameworks (TensorFlow/Keras, PyTorch)
Setting up the Development Environment
Preparing Data for Neural Networks
Defining a Feedforward Network Model
Weight Initialization Strategies
Compiling the Model: Loss and Optimizer Selection
Training the Model: The fit Method
Monitoring Training Progress (Loss and Metrics)
Evaluating Model Performance
Hands-on Practical: Training a Classifier on MNIST
Quiz for Chapter 5
Chapter 6: Regularization and Improving Performance
The Problem of Overfitting
Regularization Techniques Overview
L1 and L2 Regularization
Dropout Regularization
Early Stopping
Batch Normalization
Hyperparameter Tuning Fundamentals
Strategies for Hyperparameter Search (Grid Search, Random Search)
Hands-on Practical: Applying Dropout and Early Stopping
Quiz for Chapter 6
Chapter 7: Introduction to Specialized Architectures
Limitations of Feedforward Networks
Convolutional Neural Networks (CNNs): Motivation
Core CNN Operations: Convolution
Core CNN Operations: Pooling
Typical CNN Architecture
Recurrent Neural Networks (RNNs): Motivation
The Concept of Recurrence and Hidden State
Basic RNN Architecture
Challenges with Simple RNNs (Vanishing/Exploding Gradients)
Overview: LSTMs and GRUs
Quiz for Chapter 7
Designing and Optimizing a Deep Neural Network from Scratch

RMSprop Optimizer

While standard Gradient Descent (SGD) and its Momentum variant update all parameters using the same learning rate (potentially scaled by momentum), this might not be optimal. Imagine a loss that is very steep in one direction but quite flat in another. A single learning rate might cause oscillations in the steep direction or move too slowly in the flat direction. We need a way to adapt the learning rate individually for each parameter.

RMSprop (Root Mean Square Propagation) is an optimization algorithm designed to address this issue by maintaining a per-parameter learning rate. It achieves this by keeping track of a moving average of the squared gradients for each parameter. The core idea is to divide the learning rate for a specific weight by a running average of the magnitudes of recent gradients for that weight.

The RMSprop Mechanism

RMSprop modifies the gradient descent update rule. For each parameter (let's use a weight www as an example), it calculates an exponentially decaying average of squared gradients. Let SdwS_{dw}Sdw​ be this moving average for weight www at a given iteration. The update rule for SdwS_{dw}Sdw​ is:

Sdw=βSdw+(1−β)(∂L∂w)2S_{dw} = \beta S_{dw} + (1 - \beta) \left( \frac{\partial L}{\partial w} \right)^2Sdw​=βSdw​+(1−β)(∂w∂L​)2

Here:

  • ∂L∂w\frac{\partial L}{\partial w}∂w∂L​ is the gradient of the loss function LLL with respect to the weight www.
  • (∂L∂w)2(\frac{\partial L}{\partial w})^2(∂w∂L​)2 is the element-wise square of the gradient.
  • β\betaβ is a hyperparameter, the decay rate, typically set to a value like 0.9, 0.99, or similar. It controls how much weight is given to past squared gradients versus the current one. A higher β\betaβ means the average incorporates a longer history.
  • SdwS_{dw}Sdw​ accumulates the squared gradient information. If recent gradients for www have been large, SdwS_{dw}Sdw​ will be large, and vice-versa.

The parameter update rule then uses this moving average to scale the learning rate α\alphaα:

w=w−α∂L∂wSdw+ϵw = w - \alpha \frac{\frac{\partial L}{\partial w}}{\sqrt{S_{dw} + \epsilon}}w=w−αSdw​+ϵ​∂w∂L​​

Similarly, for a bias parameter bbb:

Sdb=βSdb+(1−β)(∂L∂b)2S_{db} = \beta S_{db} + (1 - \beta) \left( \frac{\partial L}{\partial b} \right)^2Sdb​=βSdb​+(1−β)(∂b∂L​)2 b=b−α∂L∂bSdb+ϵb = b - \alpha \frac{\frac{\partial L}{\partial b}}{\sqrt{S_{db} + \epsilon}}b=b−αSdb​+ϵ​∂b∂L​​

The term Sdw+ϵ\sqrt{S_{dw} + \epsilon}Sdw​+ϵ​ (or Sdb+ϵ\sqrt{S_{db} + \epsilon}Sdb​+ϵ​) is the root mean square (RMS) of the recent gradients that gives the algorithm its name. The small value ϵ\epsilonϵ (epsilon, e.g., 10−810^{-8}10−8) is added for numerical stability to prevent division by zero in cases where SdwS_{dw}Sdw​ might become extremely close to zero.

Intuition

How does this help?

  • Adapting Learning Rates: If the gradients for a particular weight www are consistently large, SdwS_{dw}Sdw​ will grow large. Dividing by Sdw+ϵ\sqrt{S_{dw} + \epsilon}Sdw​+ϵ​ effectively reduces the learning rate for that specific weight, preventing large steps and dampening oscillations in steep regions of the loss.
  • Accelerating Flat Directions: Conversely, if the gradients for www are small or diminishing, SdwS_{dw}Sdw​ will be small. Dividing by a small Sdw+ϵ\sqrt{S_{dw} + \epsilon}Sdw​+ϵ​ increases the effective learning rate for that weight, allowing for larger steps and faster progress in flatter regions where standard SGD might crawl.

Essentially, RMSprop automatically adjusts the step size for each parameter based on the historical magnitude of its gradients.

Advantages

Advantages:

  • Adaptive Learning Rates: Automatically adjusts learning rates on a per-parameter basis, often leading to faster convergence than SGD or Momentum on certain problems.
  • Implicit Learning Rate Tuning: Reduces the sensitivity to the choice of the global learning rate α\alphaα compared to SGD, although α\alphaα still needs to be set.

Key Points:

  • Hyperparameters: Introduces the decay rate β\betaβ and the stability term ϵ\epsilonϵ as hyperparameters, although their default values (like β=0.99\beta = 0.99β=0.99, ϵ=10−8\epsilon = 10^{-8}ϵ=10−8) often work well.
  • Not a Cure-all: While effective, RMSprop might still struggle in some complex optimization scenarios.

RMSprop was a significant step forward in optimization algorithms. It addressed the limitations of a single global learning rate by introducing per-parameter adaptation based on the magnitude of recent gradients.

Using RMSprop in PyTorch

Implementing RMSprop in a framework like PyTorch is straightforward. You simply select RMSprop from the torch.optim module when configuring your optimizer.

import torch
import torch.nn as nn
import torch.optim as optim

# Assume you have a model defined, e.g.:
# model = nn.Sequential(nn.Linear(10, 5), nn.ReLU(), nn.Linear(5, 1))
# Define input data and target labels
# inputs = torch.randn(64, 10)
# labels = torch.randn(64, 1)
# loss_fn = nn.MSELoss()

# Example: Define a simple linear model for demonstration
model = nn.Linear(10, 1) 

# Define hyperparameters
learning_rate = 0.001
# Note: PyTorch uses 'alpha' for the smoothing constant (beta in our notation)
beta_rms = 0.99 
epsilon = 1e-8 

# Instantiate the RMSprop optimizer
optimizer = optim.RMSprop(model.parameters(), 
                          lr=learning_rate, 
                          alpha=beta_rms, # This is the decay rate beta
                          eps=epsilon, 
                          momentum=0) # Standard RMSprop has no momentum term here

# --- Example Training Step ---
# Assume inputs and labels are available
# optimizer.zero_grad()          # Clear previous gradients
# outputs = model(inputs)        # Forward pass
# loss = loss_fn(outputs, labels) # Calculate loss
# loss.backward()                # Backpropagation
# optimizer.step()               # Update weights using RMSprop
# -----------------------------

print(f"Optimizer created: {optimizer}")

A simple example showing how to instantiate the RMSprop optimizer in PyTorch. Note that the parameter alpha in optim.RMSprop corresponds to the decay rate β\betaβ discussed in the algorithm description. Standard RMSprop doesn't inherently include a momentum term, although PyTorch's implementation allows adding one (set to 0 here for the basic version).

RMSprop provides an effective way to adapt learning rates during training. The next section introduces the Adam optimizer, which combines the adaptive learning rate approach of RMSprop with the momentum concept we saw earlier, creating one of the most widely used optimizers in deep learning today.

  • Lecture 6e: RMSProp. Neural Networks for Machine Learning., Geoffrey Hinton, 2012 University of Toronto (via Coursera) - Introduces the RMSprop algorithm as a method to adapt learning rates per-parameter based on a moving average of squared gradients.
  • Deep Learning, Ian Goodfellow, Yoshua Bengio, and Aaron Courville, 2016 (MIT Press) - Provides a thorough theoretical explanation of optimization algorithms, including the formulation and intuition of RMSprop.
  • torch.optim.RMSprop, PyTorch Contributors, 2024 - Official documentation for the RMSprop optimizer in PyTorch, detailing its parameters and typical use.
  • Adam: A Method for Stochastic Optimization, Diederik P. Kingma and Jimmy Ba, 2015 International Conference on Learning Representations (ICLR) DOI: 10.48550/arXiv.1412.6980 - Presents Adam, an optimizer that builds on RMSprop's adaptive learning rates by incorporating momentum, making it a valuable comparison.

© 2026 ApX Machine Learning