Neural research with explicit devices
Choose He and Xavier initialization, add Dense layers, train with Adam and measured progress, inspect CPU placement, and evaluate held out Iris data.
Download .aner source// Iris: Fisher (1936), UCI, CC BY 4.0. Native CPU Float64 training.
import aner.dataset
import aner.nn
import aner.ml
import aner.dev
print(nn.devices())
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: 8, initialization: "xavier")
.tanh()
.dense(inputs: 8, outputs: 3, initialization: "xavier")
let plan = ml.classifier(network, standardize: true,
loss: "cross_entropy", optimizer: "adam")
.on(device: "cpu")
print(plan.summary())
let fitted = plan.fit(split.train(), epochs: 400, rate: 0.02, progress: true)
dev.capture("First Dense weights", fitted.weights(layer: 0))
print("Training seconds")
print(fitted.training_seconds())
print(fitted.evaluate(split.test()).summary())
print("Prediction device")
print(fitted.predict(split.test()).device())
Make it your experiment.
With Aner installed, save this program as examples/neural_research.aner inside a folder for your experiment. Open a terminal in that folder, then check and run the program.
aner check examples/neural_research.aner
aner run examples/neural_research.anerThe 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.29 or newer. These examples explicitly select CPU Float64. Compatible native builds also support Float32 Tensor and classifier execution on available MPS or CUDA devices. Cluster requests fail without fallback. See the neural workflow guide for progress phases, optimizer continuation, and Dev/Prod inspection.
Iris and Wine are teaching datasets with their own attribution. Example outcomes are not comparative benchmarks or evidence of clinical validity.
Dataset sources & attribution