All examples
Neural networks

Fit disjoint graph regression

Keep graph membership explicit, mean pool node representations and evaluate separate supervised graph IDs.

gnn_graph_regression.aner
// Three disjoint graphs, two training targets and one held-out graph target.
import aner.nn

let graphs = nn.graph(nodes: 6,
    sources: List(0, 1, 2, 3, 4, 5),
    destinations: List(1, 0, 3, 2, 5, 4),
    graph_ids: List(0, 0, 1, 1, 2, 2))
let features: Tensor = [[-1.0], [-0.6], [0.6], [1.0], [0.2], [0.4]]
let targets: Tensor = [[-0.8], [0.8], [0.3]]
var model = nn.gnn(1, 8, 1, architecture: "gin", layers: 1)
    .task("graph_regression").on("cpu", "Float64")
var step = 0
while step < 30 {
    model = model.train_step(graphs, features, targets,
        rate: 0.01, indices: List(0, 1))
    step = step + 1
}
let validation = model.evaluate(graphs, features, targets, indices: List(2))
print(validation.summary())
print(validation.samples())
print(graphs.graph_count())
print(model.updates())

Make it your experiment.

Use the matching runtime. Save this program as examples/gnn_graph_regression.aner inside a folder for your experiment. Open a terminal in that folder, then check and run the program.

Terminal
aner check examples/gnn_graph_regression.aner
aner run examples/gnn_graph_regression.aner

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

Requires the matching Aner 0.0.7-dev.1 runtime and editor. Uses complete synthetic tensors without dataset downloads, credentials or network connections. These source additions are separate from published packages. Optional accelerators and collectives require a compatible build and hardware; CPU checks do not establish GPU or distributed performance.

Credential setup
aner check examples/gnn_graph_regression.aner
aner run examples/gnn_graph_regression.aner

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