klyn.math.nn.Sequential.compile
method
public compile(optimizer as String = "adam", loss as String = "sparse_categorical_crossentropy", metrics as IList<String> = null) as Void
Description

Resolves standard optimizer/loss names to actual typed implementations. sparse_categorical_crossentropy consumes probabilities in this overload; use an explicit loss with fromLogits=true for a linear final layer.

Parameters
ParameterDescription
optimizeradam (rate 0.001) or sgd (rate 0.01).
losssparse_categorical_crossentropy, mean_squared_error or mse.
metricsNull selects accuracy for classification and no metric for regression. Explicit regression metrics must be empty.
Throws
  • ValueException for an unsupported name or metric configuration.
Example

model.compile(optimizer="adam", loss="sparse_categorical_crossentropy", metrics=["accuracy"])