FlattenLayer class

A utility layer that flattens a multi-dimensional tensor into a 1D vector.

A FlattenLayer has no trainable parameters. Its primary role is to act as a bridge between layers that output multi-dimensional data (like ConvLSTMLayer or Conv2D) and layers that expect a 1D vector input (like DenseLayer).

Example

SNetwork model = SNetwork([
  ConvLSTMLayer(8, 3), // Outputs a 2D feature map
  FlattenLayer(),      // Flattens the map into a vector
  DenseLayer(1),       // Processes the vector
]);
Inheritance

Constructors

FlattenLayer()

Properties

hashCode int
The hash code for this object.
no setterinherited
inputCols int
getter/setter pair
inputRows int
getter/setter pair
name String
A user-friendly name for the layer (e.g., 'dense', 'lstm').
getter/setter pairoverride-getter
parameters List<Tensor>
Returns an empty list as this layer has no trainable parameters.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

build(Tensor input) → void
Records the input dimensions, which are needed for the backward pass.
override
call(Tensor input) Tensor
The public, callable interface for the layer.
inherited
forward(Tensor input) Tensor<Vector>
Unrolls the input matrix into a single, long vector.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited