Flatten
classin packageklyn.math.nn.layers
public class Flatten<T extends AbstractFloat = Float> extends Layer<T>
Flatten

Flattens sample axes while preserving the leading batch axis. The current NDArray reshape contract produces a contiguous copy of the batch, not a shared view. No full-dataset flattening is performed during fit.

Example

flatten = Flatten<Float>()

Properties
Modifier and Type Member Description
public override readonly property displayName
displayName as String
Summary label.
public override readonly property parameterCount
parameterCount as ULong
No trainable parameters.
Methods
Modifier and Type Member Description
public override buildShape
buildShape(inputShape as IList<Long>) as IList<Long>
Computes the product of the positive sample axes with overflow checking.
public override differentiate
differentiate(inputs as NDArray<T>, upstream as NDArray<T>) as LayerGradients<T>
Restores the original sample axes in the gradient.
public override forward
forward(inputs as NDArray<T>) as NDArray<T>
Copies a batch to [samples, product(sample axes)], leaving inputs unchanged.
public override parameter
parameter(index as Long) as NDArray<T>
Rejects parameter access.