ViT position plug value: sequence position to restore 2D grid
Use ViT embedded in an absolute learning position, with a vector for each patch position during training.
Learning objectives and first steps2 objectives 2 first fixes
Try to do it after reading
- Distinguishing Space token from Special token
- Location migration when understanding resolution changes
Suggested first
- Thrust and Matrix Operations
- Basic neural network
Enter resolution changes, and the number of blocks changes
Use ViT embedded in an absolute learning position, with a vector for each patch position during training. The number of patch grids may vary after changing the image resolution, and the old position table cannot be used directly at the same length. Common migration methods restore space to a two-dimensional grid, insert it into a new grid and level it up into a sequence.
The training grid 2x2 has four spatial locations, and if there is another CLS, the matrix length is 5. Nine space positions after moving to 3 x 3, for a total length of 10. CLS is not an image pixel and should normally be retained separately and not involved in two-dimensional space plugs. A square of five direct reshape will immediately expose the non-matching of the number of elements.
Even if the total number is square, the original grid should be confirmed if it is real square. Both 2x8 and 4x4 contain 16 patch, but space borders are different. The number of squares from token alone will explain the error of entering a non-square, requiring the preservation of the original high-wide grid.
Plug-in mode affects the coordinates
The spatial map of the position vector of the plug value align_corners, mode and target size. Positioning is not a real image, but consistent coordinates are still required. It is not possible to use different options for training migration and service dynamic adjustment, and then to check only the output dimensions.
Position plug-in values provide the starting point for the parameter migration and do not guarantee that the model will immediately achieve optimal performance for the new resolution. The increase in the number of patchs will also change the cost of attention and the visible details. The plug-in strategy, whether to continue fine-tuning and assessing dimensions should be recorded together, rather than “capable weighting” as proof of performance.
Models with relative or rotational position mechanisms may be transported in different ways, and not all visual Transformer are placed in an absolute position table in this section. The location mechanism used for the specific structure should be identified before a two-D plug is decided.
A minimum check can be made to the 2x2 position sheet to fill in the recognizable angle value to see if the four corners and centres after the plug-in are in accordance with the selection rules, and to confirm that the special token has not been changed. It's more reliable than the naked eye on a random high-dimensional vector.
This section is based on the original ViT paper and Torchvision, counting 5 to 10 counts derived from the synthetic structure. Any load success also requires a fixed input forward and task assessment.
2x2 space grid plus 1 CLS, how long is the table after 3x3?
9 space positions plus 1 CLS Ten of them. CLS Generally, they are retained separately.
Sixteen patchs. Can you directly identify the 4x4 grid?
No, it could be a 2x8 layout, requiring original grid shapes.
Sources and reconciliations
Definitions, methods and interfaces are available.
- An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
- Torchvision — interpolate_embeddings
Figures and calculations are reorganized according to this chapter. Mathematical measurements, framework operations and real business effects are described separately in the body of the text.