All examples
Neural networks

Explicit normal neural initialization

Fill a Dense weight matrix with an owned normal generator, preserve zero bias and retain the custom initialization seed.

random_neural_initialization.aner
// Opt-in Philox normal weights; existing NN defaults and zero biases stay intact.
import aner.random
import aner.math
import aner.nn
import aner.ml

let rng = random.generator(seed: 20261019)
let fan_in = 4
let fan_out = 8
let values = Array<Float64>(size: fan_in * fan_out, fill: 0.0)
let standard_deviation = math.sqrt(2.0 / Float64(fan_in))
for index in Range(values.len()) {
    values[index] = rng.normal(mean: 0.0, stddev: standard_deviation)
}
let weights = values.to_tensor(rows: fan_in, cols: fan_out)
let network = nn.sequential(seed: 42)
    .dense(inputs: fan_in, outputs: fan_out,
        weights: weights, bias: nn.zeros(1, fan_out))
    .relu()
    .dense(inputs: fan_out, outputs: 3, initialization: "xavier")
let classifier = ml.classifier(network, standardize: true)
print(random.engine())
print("Custom first-layer seed: " + String(rng.seed()))
print(network.summary())
print(classifier.summary())
// The final Dense stage deliberately uses the existing NN Xavier uniform API.

Make it your experiment.

With Aner 0.0.3 or newer installed, save this program as examples/random_neural_initialization.aner inside a folder for your experiment. Open a terminal in that folder, then check and run the program.

Terminal
aner check examples/random_neural_initialization.aner
aner run examples/random_neural_initialization.aner

The aner command must be on your PATH. Follow the installation guide if your terminal cannot find it.

Use Aner 0.0.3 or newer with aner.random and RandomGenerator. Earlier packaged executables may predate this module. This complete example runs locally with a retained replay seed and no external files, service or credentials. The guide explains owned cursors, addressed draws, distribution domains and numerical replay limits.

Bundled datasets retain their own source attribution and license notices. Example outcomes are not comparative benchmarks or evidence of clinical validity.

Dataset sources & attribution
Install Aner