vitClsFeature function
Take the CLS row (row 0) of a ViT encoder output. Convenience for
heads that want a [1, embedDim] image-level feature vector.
Implementation
Tensor vitClsFeature(Tensor encoded) {
if (encoded.shape.length != 2) {
throw ArgumentError(
'vitClsFeature: expected 2D [seqLen, embedDim]; got ${encoded.shape}',
);
}
return TensorAft.sliceTopLeft(encoded, 1, encoded.shape[1]);
}