Data Analytics: post #3545

How a Vision Transformer reads an image?

The image is cut into patches. Each patch is flattened and mapped by one shared linear projection E. A learnable [class] token goes in front, and a position embedding is added to every token:
z₀ = [x_class; x¹E; …; xᴺE] + E_pos

Each encoder layer: Norm → multi-head self-attention → add the input back, then Norm → MLP → add again. Repeated L times.

Only the class token's final output reaches the MLP head, which predicts the class.

https://t.me/CodeProgrammer
❤3