klyn.math.nn.optimizers.SGD.apply
method
public override apply(parameter as NDArray<T>, gradient as NDArray<T>, gradientScale as Double = 1.0) as Void
Description

Updates a parameter tensor in place: parameter -= learningRate * gradient. Shape errors are detected before any write. Non-finite values follow IEEE arithmetic; finite-gradient/loss-scaling policy belongs to the trainer.

Parameters
ParameterDescription
parameterTensor of any rank, modified in place.
gradientScalePositive finite loss scale removed before the update.
gradientTensor of the same shape and type, not modified.
Throws
  • ValueException if tensors are null, identical or have different shapes.
Example

optimizer.apply(layer.weights, derivatives.weights)