forward method
Forward pass for PatchEmbedding.
Takes a flat list of ValueVectors representing image patches.
Each ValueVector is (patchSize * patchSize * inChannels) dimensions.
Returns a list of ValueVectors, each of embedDim dimensions.
In a full image pipeline, you'd reshape your image (H, W, C) into (num_patches, patchSizepatchSizeC) first.
Implementation
List<ValueVector> forward(List<ValueVector> imagePatches) {
// Each imagePatch in the list is already flattened (patchSize*patchSize*inChannels)
// Project each flattened patch to embedDim
final projectedPatches =
imagePatches.map((patch) => projection.forward(patch)).toList();
// Apply layer normalization
final normalizedPatches =
projectedPatches.map((patch) => norm.forward(patch)).toList();
return normalizedPatches;
}