LayerGraphBuilder<T>

Helpers & Utilities · AiDotNet.NeuralNetworks.Graph

Fluent construction of a LayerGraph: add each layer and say what feeds it.

Example

var g = new LayerGraphBuilder<double>();
int stem = g.Add(new DenseLayer<double>(32));            // consumes the model input
int trunk = g.Add(new DenseLayer<double>(32), stem);
int headA = g.Add(new DenseLayer<double>(4), trunk);      // both heads read the trunk:
int headB = g.Add(new DenseLayer<double>(2), trunk);      // this is the fan-out
g.Output(headA);

Constructors

Constructor Summary
LayerGraphBuilder()

Methods

Method Summary
LayerGraph<T> Build() Builds the graph.
LayerGraphBuilder<T> Output(int nodeId) Declares which node’s output is the model’s output.
int Add(ILayer<T> layer) Adds a layer fed by the model input.
int Add(ILayer<T> layer, int input) Adds a layer fed by one earlier node.
int AddJoin(ILayer<T> layer, IReadOnlyList<int> inputs, Func<IReadOnlyList<Tensor<T>>, Tensor<T>> combine, string description) Adds a layer fed by SEVERAL earlier nodes, combined by combine.
int AddVia(ILayer<T> layer, int input, Func<Tensor<T>, Tensor<T>> transform, string description) Adds a layer fed by one earlier node through a transformation — a reshape, permute or similar.