ReferenceTrainer

The local training step in pure Kotlin: one gradient-descent step of linear regression (y ≈ w·x + b) over a batch, mean-squared-error loss. This is the oracle the wasm kernel (fedavg_train.wasm) is proven bit-for-bit equal to (see FedAvgKernelEquivalenceTest).

Dimension is fixed at D = 2 (one feature + bias) to match the v1 kernel; step's weight vector is [featureWeight, bias].

Functions

Link copied to clipboard
fun step(weights: List<Double>, examples: List<Pair<Double, Double>>, learnRate: Double): List<Double>

One GD step. examples are (x, y) pairs. Returns the updated [w0', b'].