public class Sequential<T extends AbstractFloat = Float>
Ordered composition of typed layers for classification and regression. Classification consumes Int labels; regression consumes targets in T. Input declarations build the network immediately; otherwise dimensions are inferred on the first fit, evaluate or predict call. Layers are not cloned: keep distinct instances per stage and per independent model. A model is not safe for concurrent training/prediction or parameter mutation. CPU training keeps batches ordered. Sufficiently large matrix products and independent optimizer ranges use shared native workers; small operations remain serial to avoid scheduling overhead. Reductions keep their order. Float16 keeps parameter/activation buffers in FP16, with FP32 matrix accumulation and Adam state. Training scales gradients dynamically and skips non-finite updates before reducing the scale. Optimizer state is not included in the parameter memory reported by summary().
model = Sequential<Float>([Dense<Float>(128), Dense<Float>(10)])
| Modifier and Type | Member | Description |
|---|---|---|
| public readonly property | devicedevice as Device |
Concrete device most recently resolved, or auto before resolution. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | SequentialSequential(layers as IList<Layer<T>>) |
Snapshots the order of a non-empty list of layers without copying parameters. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | compilecompile(optimizer as Optimizer<T>, loss as ClassificationLoss<T>, metrics as IList<String> = ["accuracy"]) as Void |
Configures the optimizer and mean classification loss without resetting weights. |
| public | compilecompile(optimizer as Optimizer<T>, loss as RegressionLoss<T>, metrics as IList<String> = []) as Void |
Configures a typed floating-target regression objective. |
| public | compile | Resolves standard optimizer/loss names to actual typed implementations. |
| public | evaluateevaluate(notnull features as NDArray<T>, notnull labels as NDArray<Int>, batchSize as Long = 64l) as Evaluation |
Evaluates fixed parameters, without shuffling or optimizer updates. |
| public | evaluateevaluate(notnull features as NDArray<T>, notnull targets as NDArray<T>, batchSize as Long = 64l) as Evaluation |
Computes sample-weighted regression loss with fixed parameters and no optimizer updates. |
| public | fit | Trains with shuffled minibatches and sample-weighted metrics. |
| public | fit | Trains on same-precision floating targets using the configured regression loss. |
| public static | loadload(filename as String, maxBytes as ULong = 2147483648ul) as Sequential<T> |
Restores using a filename; identical to the Path overload. |
| public static | loadload(path as Path, maxBytes as ULong = 2147483648ul) as Sequential<T> |
Restores an independent model, including all saved training state. |
| public | loadWeights | Loads weights using a filename. |
| public | loadWeights | Loads parameters transactionally into an identically configured built model. |
| public | predict | Computes model outputs without applying any implicit output activation. |
| public | save | Saves using a filename; identical to the Path overload. |
| public | save | Saves architecture, exact parameter bits and optional training state to KNN 1.0. |
| public | summarysummary() as Void |
Prints layer names, output shapes, trainable scalar counts and parameter bytes. |
| public | toto(device as Device) as Sequential<T> |
Selects execution without resetting parameters, optimizer state or precision. |