SNetwork class

A sequential neural network architecture that linearly stacks and executes Layer instances. Manages sequential forward propagation, parameter aggregation across constituent layers, training loops via fit, weight serialization to JSON via save and load, and autograd graph visualization.

Inheritance

Constructors

SNetwork(List<Layer> layers, {String name = 'snetwork'})
Creates an SNetwork with the given layers sequence and optional name.

Properties

hashCode → int
The hash code for this object.
no setterinherited
layers ↔ List<Layer>
Ordered list of Layer instances composing the sequential pipeline.
getter/setter pair
name ↔ String
The assigned name of this network architecture for debugging and inspection.
getter/setter pairoverride-getter
optimizer ↔ Optimizer
The Optimizer assigned via compile to update network parameters during training.
getter/setter pair
parameters → List<Tensor>
Returns all trainable parameters aggregated across every layer in layers.
no setteroverride
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

build(Tensor input) → void
Allocates and initializes weights/biases based on the incoming input shape. The Tensor input will be used for the setup and therefore should match the exact Tensor shape used in forward.
inherited
call(Tensor input) → Tensor
Helper function that, if not overwritten, checks whether build has already been called; if not, it calls build and only then forward.
inherited
compile({required Optimizer configuredOptimizer}) → void
Configures the network by binding the specified configuredOptimizer for subsequent training.
evaluate(List<List<double>> inputs, List<List<double>> targets) → double
Computes binary classification accuracy on inputs and targets by thresholding predictions at 0.5.
fit(List<List<double>> inputs, List<List<double>> targets, {int epochs = 100, bool averageWeight = false, bool debug = true}) → void
Trains the network parameters on provided inputs and targets over epochs using MSE loss and the assigned optimizer.
forward(Tensor input) → Tensor
Sequentially executes the forward pass across each layer in layers, routing each output to the subsequent layer.
override
getWeights() → Map<String, dynamic>
Serializes the weights of all parameterized layers into an indexed map.
override
inspectGraph(List<double> inputData, List<double> targetData) → void
Executes a forward pass with inputData and targetData to compute MSE loss and prints the autograd compute graph.
load(String filePath) → Future<void>
Reads serialized network weights from a JSON file at filePath and applies them to the network layers.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
predict(Tensor input) → Tensor
Executes an inference pass on the given input tensor by invoking the layer call pipeline.
save(String filePath) → Future<void>
Serializes network weights into formatted JSON and saves the output to filePath.
setWeights(Map<String, dynamic> networkWeights) → void
Deserializes and loads weights into each parameterized layer from the provided networkWeights map.
override
toString() → String
A string representation of this object.
inherited

Operators

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