Table of Contents

Class RmsPropGpuConfig

Namespace
AiDotNet.Interfaces
Assembly
AiDotNet.dll

Configuration for RMSprop optimizer on GPU.

public class RmsPropGpuConfig : IGpuOptimizerConfig
Inheritance
RmsPropGpuConfig
Implements
Inherited Members

Remarks

RMSprop maintains a moving average of squared gradients to normalize the gradient. This helps with non-stationary objectives and is particularly useful for RNNs.

For Beginners: RMSprop adapts the learning rate by dividing by a running average of gradient magnitudes. This helps training be more stable when gradients vary a lot in size - common in recurrent neural networks.

Constructors

RmsPropGpuConfig(float, float, float, float, int)

Creates a new RMSprop GPU configuration.

public RmsPropGpuConfig(float learningRate, float rho = 0.9, float epsilon = 1E-08, float weightDecay = 0, int step = 0)

Parameters

learningRate float

Learning rate for parameter updates.

rho float

Decay rate for moving average (default 0.9).

epsilon float

Numerical stability constant (default 1e-8).

weightDecay float

Weight decay coefficient (default 0).

step int

Current optimization step.

Properties

Epsilon

Gets the small constant for numerical stability (typically 1e-8).

public float Epsilon { get; init; }

Property Value

float

LearningRate

Gets the learning rate for parameter updates.

public float LearningRate { get; init; }

Property Value

float

OptimizerType

Gets the type of optimizer (SGD, Adam, AdamW, etc.).

public GpuOptimizerType OptimizerType { get; }

Property Value

GpuOptimizerType

Rho

Gets the decay rate for the moving average (typically 0.9).

public float Rho { get; init; }

Property Value

float

Step

Gets the current optimization step (used for bias correction in Adam-family optimizers).

public int Step { get; init; }

Property Value

int

WeightDecay

Gets the weight decay (L2 regularization) coefficient.

public float WeightDecay { get; init; }

Property Value

float

Methods

ApplyUpdate(IDirectGpuBackend, IGpuBuffer, IGpuBuffer, GpuOptimizerState, int)

Applies the optimizer update to the given parameter buffer using its gradient.

public void ApplyUpdate(IDirectGpuBackend backend, IGpuBuffer param, IGpuBuffer gradient, GpuOptimizerState state, int size)

Parameters

backend IDirectGpuBackend

The GPU backend to execute the update.

param IGpuBuffer

Buffer containing the parameters to update (modified in-place).

gradient IGpuBuffer

Buffer containing the gradients.

state GpuOptimizerState

Optimizer state buffers (momentum, squared gradients, etc.).

size int

Number of parameters to update.

Remarks

For Beginners: This method applies the optimizer's update rule directly on the GPU. Each optimizer type (SGD, Adam, etc.) implements its own update logic using GPU kernels. The state parameter contains any auxiliary buffers needed (like velocity for SGD with momentum, or m/v buffers for Adam).

Design Note: Following the Open/Closed Principle, each optimizer config knows how to apply its own update, so adding new optimizers doesn't require modifying layer code.