pvt_v2 (image classification)
PVTv2: a pyramid vision transformer backbone with spatially reduced attention and no position embeddings.
Image classification · 360 operations Checked
Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.
At a glance
- Task
- Image classification
- Parameters
- 3.4M
- Operations
- 360
- Framework
- PyTorch
- Recurrent
- No
- Source
- transformers 5.18.0
- Name in source
- pvt_v2:image-classification
- License
- Apache-2.0
- Checked
- Passed: the trace was replayed operation by operation and matched the model's own output for this input.
Files
The file opened in a new tab. Use your browser's Save command there to keep it.
The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.
Details
- Stable ID
- m8419
- Graph hash
- 06d8cae9d7b334e032b8af739be3f9d524be87eec2292ac8d915352f0b6132d5
- Skeleton hash
- 7b757fe18589529804993cc443a96d1ce67808d87147c13b7d1b67677f49a939
- Architecture hash
- 62ee71b5078d4ae7e181a58ee05daf46005957e4f176a7c6965641313d18b952
- Diagram SHA-256
- 621bd42ff927a7e87b607cb263dad9c8e31cae242dbd7d8f4908357d7819a22f
- TorchLens version
- 2.36.0
- Renderer
- graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
- Check
- Forward pass replayed in PyTorch
How this diagram was made
transformers.AutoModelForImageClassification.from_config()
What it is
PVTv2, the Pyramid Vision Transformer V2, belongs to the hierarchical transformers, which adapt transformer layers to generate multi-scale feature maps. It improves on the original PVT v1 with three designs: a linear complexity attention layer, overlapping patch embedding, and a convolutional feed-forward network. It drops position embeddings entirely, relying on positional information from zero-padding and overlapping patch embeddings, so inference runs at any resolution with nothing to interpolate.
Attention cost is cut by Spatial Reduction Attention, which uses 2D convolutions to project hidden states to a smaller resolution before the queries attend to them, taking self-attention from O(n^2) to O(n^2/R). An optional Linear SRA instead average-pools the hidden states to a fixed size for linear complexity in image size, at the cost of being more lossy. The same encoder structure has been deployed in Segformer for semantic segmentation, GLPN for monocular depth, and Panoptic Segformer for panoptic segmentation. At 224 resolution the smallest size, PVT-V2-B0, reaches 70.5 top-1 on ImageNet-1K with 3.7M parameters.
Key idea. Three changes over PVT v1: a linear complexity attention layer, overlapping patch embedding and a convolutional feed-forward network.
- pvt v2
- pvtv2
- pyramid vision transformer
- mix transformer
- mit
- spatial reduction attention
- sra
- linear sra
- image classification
- backbone
AI-written summary, based on the model's documentation and checked automatically against it; not reviewed by a person. Corrections welcome.