SeqModel<InputType, OutputType> class

Sequential aid for constructing models to run. The Sequential Model wraps a list of TapeLayers to manage static graph compilation via command tapes. It handles VRAM lifecycles, training loops, and high-speed inference.

Constructors

SeqModel(List<TapeLayer> layers, GPUTensor<InputType> input, {GPUTensor<OutputType>? target, GPUTensor<Scalar> lossFunction(GPUTensor<OutputType>, GPUTensor<OutputType>, CommandBuffer, {GPUTensor<Scalar>? outTensor})?, OptimizerGPU optimizerBuilder(List<GPUTensor>)?})
Initializes the Sequential Model with a list of layers and the training input tensor. Optionally accepts a target tensor, lossFunction, and an optimizerBuilder for training workflows.

Properties

hashCode → int
The hash code for this object.
no setterinherited
inferInput ↔ GPUTensor<InputType>?
The entry point tensor mapped to the inference static graph.
getter/setter pair
inferResult ↔ GPUTensor<OutputType>?
The final output tensor produced by the inferTape.
getter/setter pair
inferTape ↔ CommandBuffer?
The compiled lightweight command buffer used exclusively for inference.
getter/setter pair
input ↔ GPUTensor<InputType>
The entry point tensor used to trace the training graph.
getter/setter pair
layers ↔ List<TapeLayer>
The ordered list of layers making up the sequential network.
getter/setter pair
loss ↔ GPUTensor<Scalar>?
The scalar tensor holding the computed loss value.
getter/setter pair
lossFunction ↔ GPUTensor<Scalar> Function(GPUTensor<OutputType>, GPUTensor<OutputType>, CommandBuffer, {GPUTensor<Scalar>? outTensor})?
The function used to calculate the loss between the network's output and the target.
getter/setter pair
optimizer ↔ OptimizerGPU?
The optimizer responsible for updating layer weights based on calculated gradients.
getter/setter pair
optimizerBuilder ↔ OptimizerGPU Function(List<GPUTensor>)?
A callback that builds the optimizer once all layer parameters are allocated in VRAM.
getter/setter pair
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
target ↔ GPUTensor<OutputType>?
The expected output tensor used for loss calculation during training.
getter/setter pair
trainBackward ↔ CommandBuffer
The compiled static command buffer for backpropagation.
getter/setter pair
trainForward ↔ CommandBuffer
The compiled static command buffer for the forward pass during training.
getter/setter pair
trainOptimize ↔ CommandBuffer
The compiled static command buffer for weight updates and gradient clearing.
getter/setter pair

Methods

compile() → void
Compiles the static training tapes for forward execution, backpropagation, and optimization. It allocates all layer parameters in VRAM, chains their forward passes, and records the gradient memory lifecycle.
free() → void
Frees all VRAM allocations associated with the layers, including weights, biases, and intermediate caches.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
predict(GPUTensor<InputType> newInferInput) → GPUTensor<OutputType>
Compiles a lightweight static inference tape tailored to the shape of newInferInput. This safely resizes internal layer VRAM caches (e.g., matching a batch size of 1) and returns the output tensor reference.
runForward({List<double>? inputData}) → void
Executes the pre-compiled inference tape. If inputData is provided, it pushes the new raw bytes directly into the VRAM of the inference tensor before running.
runTraining({List<double>? inputData, List<double>? targetData}) → void
Executes a single full training step consisting of the Forward, Backward, and Optimize tapes. Optionally accepts inputData and targetData to overwrite the respective VRAM buffers before execution.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited