A research class with native replica training
Organize an explicit Dense architecture and immutable training configuration in a class, then select replica placement independently.
Download .aner source// A class organizes a research experiment around the native checked fit API.
// The class instance is local; only supported model/data buffers reach workers.
import aner.dataset
import aner.nn
import aner.ml
import aner.parallel
class ResearchClassifier {
let model: ClassifierPipeline
let config: TrainingConfig
fn train(training: Dataset, execution: ParallelContext) {
return parallel.fit(model: model, data: training,
config: config, execution: execution)
}
}
let parts = dataset.iris().partition(validation: 0.2, test: 0.2, seed: 42)
let experiment = ResearchClassifier(
model: ml.classifier(nn.mlp(4, List(8), 3, 42),
standardize: true, loss: "cross_entropy", optimizer: "adam"),
config: ml.training(epochs: 40, batch: 32, rate: 0.01, seed: 42)
.validation(parts.validation()))
let fitted = experiment.train(parts.train(),
parallel.device(device: "cpu", dtype: "Float64"))
print(fitted.evaluate(parts.test()).summary())
Make it your experiment.
With Aner installed, save this program as examples/parallel/neural_class.aner inside a folder for your experiment. Open a terminal in that folder, then check and run the program.
aner check examples/parallel/neural_class.aner
aner run examples/parallel/neural_class.anerThe aner command must be on your PATH. Follow the installation guide if your terminal cannot find it.
Use the compatible native Aner development engine and VS Code extension 0.1.33. The local programs require no remote configuration. Strict CPU/CUDA supports Float64 and Float32; Metal/MPS requires Float32. Configured groups require private enrollment accessible only to its owner and installed workers with compatible source. See Distributed neural training for placement, protected roles, weighted gradients and Dev observation limits.
Iris and Wine are teaching datasets with their own attribution. Example outcomes are not comparative benchmarks or evidence of clinical validity.
Dataset sources & attribution