NativeBackpropagation<P extends NativeSample> class

Backpropagation trainer accelerated by a native CPU/Metal backend.

Drop-in replacement for Backpropagation on Float32x4 networks. When no native backend is available it behaves exactly like Backpropagation.

Inheritance

Constructors

NativeBackpropagation(ANN<double, Float32x4, SignalFloat32x4, Scale<double>> ann, SamplesSet<P> samplesSet, {NativeBackend backend = NativeBackend.auto, String? subject})

Properties

activeBackend NativeBackend
The backend actually in use (NativeBackend.none when running pure-Dart).
no setterinherited
algorithmName String
The training algorithm name.
finalinherited
ann ANN<double, Float32x4, SignalFloat32x4, Scale<double>>
The ANN to train.
finalinherited
backend NativeBackend
final
bestTrainingError double
The lowest training error seen by checkBestTrainingError since the last resetBestTraining.
no setterinherited
elapsedTime Duration?
no setterinherited
enableSelectInitialANN bool
If true will select the initial ANN calling selectInitialANN.
getter/setter pairinherited
endTime DateTime?
The end time of the last training session or null if not finished yet.
no setterinherited
globalError double
Returns the current training global error (set by train).
no setterinherited
globalLearnError double
The global error while updating weights.
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
initialAnnEpochs int
Number of epochs to perform in the ANNs in the selection pool.
getter/setter pairinherited
initialAnnPoolSize int
The initial ANN pool size.
getter/setter pairinherited
isNativeAccelerated bool
Whether a native backend is active for this trainer.
no setterinherited
lastGlobalError double
no setterinherited
lastGlobalLearnError double
The previous global error while updating weights.
no setterinherited
learningRate double
Returns the current learning rate of the Backpropagation.
no setterinherited
learningRateEntry Float32x4
no setterinherited
logEnabled bool
If true logging will be enabled.
getter/setter pairinherited
logger TrainingLogger
finalinherited
logProgressEnabled bool
If true logging of progress will be enabled.
getter/setter pairinherited
momentum double
Returns the current momentum rate of the Backpropagation.
no setterinherited
momentumEntry Float32x4
no setterinherited
noImprovementLimit int
Limit of epochs without improvements. Used to trigger strategies.
no setterinherited
noImprovementRatio double
Minimal improvement ratio.
getter/setter pairinherited
parameters String
no setterinherited
random Random
no setterinherited
requestedBackend NativeBackend
The requested backend (defaults to NativeBackend.auto).
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
samples List<P>
Returns the samples of samplesSet
no setterinherited
samplesSet SamplesSet<P>
The samples set for training.
finalinherited
samplesSubject String
Returns the subject of samplesSet
no setterinherited
signalInstance SignalFloat32x4
no setterinherited
startTime DateTime?
The start time of the last training session or null if reset.
no setterinherited
subject String
The training subject. Defaults to samplesSet.subject.
finalinherited
totalFailedEpochs int
no setterinherited
totalTrainedEpochs int
Returns the total number of epochs of all the training session. A call to reset won't reset this value.
no setterinherited
totalTrainingActivations int
Returns the total number of activations of all the training session. A call to reset won't reset this value.
no setterinherited
trainedEpochs int
Returns the number of epochs of the last training session.
no setterinherited
trainingActivations int
Returns the number of activations of the last training session.
no setterinherited
trainingSamplesSize int
no setterinherited

Methods

activateNative(SignalFloat32x4 input) List<double>?
Runs a native forward pass (inference) for input and returns the output layer values, or null when no native backend is active.
inherited
backPropagateLastLayerError(Layer<double, Float32x4, SignalFloat32x4, Scale<double>> layer, int layerIndex, SignalFloat32x4 expected) → void
inherited
backPropagateMiddleLayerError(Layer<double, Float32x4, SignalFloat32x4, Scale<double>> layer, int layerIndex) → void
inherited
checkBestTrainingError(double trainingError) → void
inherited
computeEntryWeightUpdate(Float32x4 weight, Float32x4 weightLastUpdate, Float32x4 gradient, Float32x4 previousGradient, SignalFloat32x4 previousUpdateDeltas, SignalFloat32x4 noImprovementCounter, int weightsEntryIndex, Float32x4 neuronOutput) Float32x4
inherited
computeEntryWeightUpdateSIMD(Float32x4 weight, Float32x4 weightLastUpdate, Float32x4 gradient, Float32x4 previousGradient, SignalFloat32x4 previousUpdateDeltas, SignalFloat32x4 noImprovementCounter, int weightsEntryIndex, Float32x4 neuronOutput) Float32x4
Implementation of the weight update for an entry (SIMD).
inherited
computeGlobalError(List<P> samples) double
inherited
computeWeightUpdate(double weight, double weightLastUpdate, num gradient, num previousGradient, List<num> previousUpdateDeltas, List<num> noImprovementCounter, int weightIndex, double neuronOutput) double
Implementation of the weight update.
inherited
createLearningRateStrategy() ParameterStrategy<double, Float32x4, SignalFloat32x4>
inherited
createMomentumStrategy() ParameterStrategy<double, Float32x4, SignalFloat32x4>
inherited
createWeightStateBuffers({double fill = 0}) List<List<SignalFloat32x4>>
Allocates a per-weight state buffer group with the same shape as the network weights (per layer -> per source neuron -> Signal over the target neurons), initialized to fill. The group is registered so reset reinitializes it. Optimizer subclasses use this for their persistent state (e.g. Adam's first/second moments).
inherited
generateRandomValue(double range) double
inherited
generateRandomValuePositive(double range) double
inherited
generateRandomWeightUpdate(double range, double min, double max, double multiplier) double
inherited
generateRandomWeightUpdateByFactor(double weight, double factor, {double zeroPoint = 0.01, double multiplier = 1.0}) double
inherited
initializeParameters() → void
Initialize training parameters.
inherited
initializeTraining() → void
inherited
learn(List<P> samples, double targetGlobalError) bool
Learn the training of sample. Called by train.
inherited
loadGradients(List state) → void
Restores gradients previously produced by saveGradients.
inherited
loadOptimizerState(List state) → void
Restores optimizer state previously produced by saveOptimizerState.
inherited
logError(String message, [dynamic error, StackTrace? stackTrace]) → void
inherited
logInfo(String message) → void
inherited
logProgress(String message) → void
inherited
logWarn(String message) → void
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
recordTrainingBlock(double globalError, int epochs) → void
Records the outcome of an externally-driven training block (e.g. the async WebGPU trainers, which run epochs off the synchronous _trainImpl loop) so the public bookkeeping getters (globalError, trainedEpochs, totalTrainedEpochs, trainingActivations) reflect it. Also updates the best-training snapshot via checkBestTrainingError.
inherited
reset() → void
Reset this instance for a future training sessions.
inherited
resetBestTraining() → void
Discards the best weights/error tracked by checkBestTrainingError.
inherited
restoreGlobalLearnErrors(double last, double current) → void
Restores the epoch error-tracking used by iRProp+ backtracking (and by the learning-rate/momentum strategies). Used when resuming from a checkpoint.
inherited
saveGradients() List<List<List<double>>>
Serializes the current accumulated gradients (layer.gradients) — the value that becomes previousGradient on the next epoch's resetGradients. Needed for an exact checkpoint resume of optimizers that read the previous gradient (Quickprop, iRProp+).
inherited
saveOptimizerState() List<List<List<double>>>
Serializes the registered optimizer state buffers (for checkpointing). Each buffer group is flattened to a list of per-source-neuron value lists (layer-major, matching the allocation order).
inherited
selectInitialANN(List<P> samples, double targetGlobalError, [Random? random]) → void
Selects the initial ANN.
inherited
setLearningRate(double learningRate) → void
inherited
setMomentum(double momentum) → void
inherited
toString() String
A string representation of this object.
inherited
train(int epochs, double targetGlobalError) double
Train the samples for n epochs and returns the last global error.
inherited
trainUntilGlobalError({double? targetGlobalError, int epochsBlock = 50, int maxEpochs = 1000000, double maxEpochsLimitRatio = 3, int maxRetries = 5, double retryIncreaseMaxEpochsRatio = 1.50, Random? random}) bool
Train the ann until targetGlobalError, with maxEpochs per training session and a maxRetries when a training session can't reach the target global error.
inherited
updateGlobalLearnError(double globalLearnError) → void
Publishes the epoch's learn error, rolling the previous value.
inherited
updateLayerWeights(Layer<double, Float32x4, SignalFloat32x4, Scale<double>> layer, int layerIndex) → void
inherited
updateParameters() → void
Update training parameters.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited