All models

tnt (MMPretrain)

A vision transformer that runs attention inside each patch as well as between patches.

Image classification · 82 operations Checked

100%

Showing the top corner; full diagram not loaded yetShowing a small copy; full diagram not loaded yetLarge diagram, not loaded yet

Open SVG

Loading diagram (21 KB)

Open in a new tab

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

Family
tnt
Parameters
731.4K
Operations
82
Framework
PyTorch
Recurrent
No
Source
timm 1.0.30
Name in source
mmpretrain:tnt
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 diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.

Details
Stable ID
m7006
Graph hash
a626311f623ba0bd7c56b49944c19000c8463ff1c62ad627f89f1f740cfeffc4
Skeleton hash
7689e4e68f357a70fcb78c9f335eb177900c53e1962a9774027eb87b81abfdb0
Architecture hash
134a258a6fffc37701a85653acade6a231949e82d3e3663968e6105268954f18
Diagram SHA-256
ce4c3f5874377d7fa748188c402b778f39ccfe0ee213ac64c67e818a8e095850
TorchLens version
2.35.3
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

menagerie.classics.wave_b_openmmlab:build_mmpretrain: build({})

What it is

About this model's family

Transformer in Transformer (TNT) is a vision transformer that applies attention inside each image patch as well as between patches. The paper argues that, for natural images with abundant detail and color information, ordinary patch division is not fine enough to pick out features of objects at different scales and locations.

TNT treats each 16×16 patch as a visual sentence and divides it further into 4×4 patches called visual words. In each block, an inner transformer block models the relationships between the words of one sentence, and an outer transformer block works on the sequence of sentences. In every layer the word embeddings are linearly projected and added into the sentence embedding, and at the end a classification token serves as the image representation.

The paper defines three sizes, TNT-Ti, TNT-S and TNT-B, and reports 6.1M, 23.8M and 65.6M parameters for them. On ImageNet it reports 81.5% top-1 accuracy for TNT-S, 1.7% higher than its DeiT-S baseline. It also notes that every transformer-based model in its comparison was still behind EfficientNet.

Key idea. Transformer in Transformer computes attention among the small visual words inside each patch as well as among the patches, and aggregates the features of both.

  • TNT
  • transformer in transformer
  • transformer-in-transformer
  • visual words
  • visual sentences
  • visual transformer
  • image classification
  • TNT-S
  • TNT-B

AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.