SNetwork class
A sequential model that stacks layers linearly.
SNetwork provides a high-level API for building, training, and evaluating
neural networks, similar to Keras's Sequential model. It manages the
network's layers, parameters, and the entire training lifecycle.
Example
// 1. Define the model
var network = SNetwork([
DenseLayer(8),
ReLULayer(),
DenseLayer(1),
]);
// 2. Compile the model
network.compile(
configuredOptimizer: Adam(network.parameters, learningRate: 0.01)
);
// 3. Train and evaluate
network.fit(inputs, targets, epochs: 100);
network.evaluate(inputs, targets);
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
-
layers
→ List<
Layer> -
final
- name → String
-
A user-friendly name for the layer (e.g., 'dense', 'lstm').
final
- optimizer ↔ Optimizer
-
getter/setter pair
-
parameters
→ List<
Tensor> -
A list of all trainable tensors (weights and biases) in the layer.
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
build(
Tensor input) → void -
Initializes the layer's parameters based on the shape of the first input.
inherited
-
call(
Tensor input) → Tensor -
The public, callable interface for the layer.
inherited
-
compile(
{required Optimizer configuredOptimizer}) → void -
evaluate(
List< List< inputs, List<double> >List< targets) → voiddouble> > -
fit(
List< List< inputs, List<double> >List< targets, {int epochs = 100, bool averageWeight = false, bool debug = true}) → voiddouble> > -
forward(
Tensor input) → Tensor -
The core logic of the layer's transformation.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
predict(
Tensor input) → Tensor -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited