All examples
Neural networks

Classifier precision policies

Train a seeded Iris classifier under one explicit execution profile, then inspect effective parameters, optimizer state, evaluation, and duration.

Download .aner source
neural_precision.aner
// The classifier captures the selected execution profile before fitting.
import aner.nn
import aner.ml
import aner.dataset
import aner.dev

print(nn.execution())
let split = dataset.iris().split(test: 0.2, seed: 2026)
let network = nn.sequential(seed: 42)
    .dense(inputs: 4, outputs: 16, initialization: "he").relu()
    .dense(inputs: 16, outputs: 3, initialization: "xavier")
let plan = ml.classifier(network, standardize: true,
    loss: "cross_entropy", optimizer: "adam")
print(plan.summary())
let fitted = plan.fit(split.train(), epochs: 20, rate: 0.02, progress: true)
let weights = fitted.weights(0)
print(weights.dtype())
print(weights.device())
print(weights.backend())
print(fitted.initial_loss())
print(fitted.training_loss())
print(fitted.evaluate(split.test()).accuracy())
dev.capture(label: "fitted weights", value: weights)

Make it your experiment.

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

Terminal
aner check examples/neural_precision.aner
aner run examples/neural_precision.aner

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

Use the updated native Aner interpreter and VS Code extension 0.1.30 or newer. Execution defaults to CPU Float64 preserve. Choose --device auto --precision Float64 --precision-policy preserve, adapt, or fast without changing the numerical source. CPU and compiled CUDA support Float64/Float32; native Metal/MPS supports Float32, so preserve uses reported CPU Float64 fallback. Explicit unavailable accelerators fail. Precision changes and fallback remain visible in Dev and Prod. See Tensor devices and performance for exact policy, conversion, and complexity contracts.

Iris and Wine are teaching datasets with their own attribution. Example outcomes are not comparative benchmarks or evidence of clinical validity.

Dataset sources & attribution
Install Aner