Class GradientDescentOptimizer
- Namespace
- NeuralNetworks.Optimizers
- Assembly
- NeuralNetworks.dll
Implements the classic "Stochastic" Gradient Descent (SGD) optimizer for neural network training. Updates parameters by subtracting the scaled gradient using a specified learning rate.
public class GradientDescentOptimizer : Optimizer
- Inheritance
-
GradientDescentOptimizer
- Inherited Members
Remarks
This optimizer supports parameter updates for 1D, 2D, and 4D float arrays.
There is no actual "stochastic" aspect implemented here, so the name of this class reflects that ("GradientDescentOptimizer" instead of "StochasticGradientDescentOptimizer").Constructors
GradientDescentOptimizer(LearningRate)
Implements the classic "Stochastic" Gradient Descent (SGD) optimizer for neural network training. Updates parameters by subtracting the scaled gradient using a specified learning rate.
public GradientDescentOptimizer(LearningRate learningRate)
Parameters
learningRateLearningRate
Remarks
This optimizer supports parameter updates for 1D, 2D, and 4D float arrays.
There is no actual "stochastic" aspect implemented here, so the name of this class reflects that ("GradientDescentOptimizer" instead of "StochasticGradientDescentOptimizer").Methods
ToString()
Returns a string representation of the optimizer, including the learning rate.
public override string ToString()
Returns
- string
A string describing the optimizer and its learning rate.
Update(Layer?, float[,,,], float[,,,])
Updates a 4D parameter array using the gradient and the current learning rate.
public override void Update(Layer? layer, float[,,,] param, float[,,,] paramGradient)
Parameters
layerLayerThe layer whose parameters are being updated (may be null).
paramfloat[,,,]The 4D parameter array to update.
paramGradientfloat[,,,]The 4D gradient array corresponding to
param.
Update(Layer?, float[,], float[,])
Updates a 2D parameter array using the gradient and the current learning rate.
public override void Update(Layer? layer, float[,] param, float[,] paramGradient)
Parameters
layerLayerThe layer whose parameters are being updated (may be null).
paramfloat[,]The 2D parameter array to update.
paramGradientfloat[,]The 2D gradient array corresponding to
param.
Update(Layer?, float[], float[])
Updates a 1D parameter array using the gradient and the current learning rate.
public override void Update(Layer? layer, float[] param, float[] paramGradient)