klyn.math.nn.serialization.ModelArchive.write
method
public static write(path as Path, layers as IList<Layer<T>>, inputShape as IList<Long>, optimizer as Optimizer<T>, loss as ClassificationLoss<T>, gradientScale as Double, finiteBatches as Long, includeOptimizer as Boolean = true, regressionLoss as RegressionLoss<T> = null) as Void
Description

Writes a built sequential model using bounded I/O and atomic replacement. Optimizer states describe continuation between fit calls; datasets, batches and the call-local shuffle permutation are not saved. No concurrent model mutation is permitted. Temporary files are private and always cleaned up.

Parameters
ParameterDescription
pathDestination; no extension or .knn, never an external format.
layersOrdered allowlisted stages with initialized parameters.
inputShapeBuilt input dimensions, excluding the batch axis.
optimizerUpdate rule or null. @param loss Classification loss or null.
regressionLossRegression objective or null; mutually exclusive with loss.
gradientScaleDynamic loss scale. @param finiteBatches Growth counter.
includeOptimizerFalse produces an uncompiled inference checkpoint.
Throws
  • ValueException for unbuilt/unsupported components; IOException for I/O.
Example

ModelArchive<Float>.write(path, layers, [784l], optimizer, loss, 1.0, 0l)