Papers › Transformer in Transformer
Transformer in Transformer
Kai Han, An Xiao, Enhua Wu, Jianyuan Guo, Chunjing Xu, Yunhe Wang
Transformer is a new kind of neural architecture which encodes the input data as powerful features via the attention mechanism. Basically, the visual transformers first divide the input images into several local patches and then calculate both representations and their relationship. Since natural images are of high complexity with abundant detail and color information, the granularity of the patch dividing is not fine enough for excavating features of objects in different scales and locations. In this paper, we point out that the attention inside these local patches are also essential for building visual transformers with high performance and we explore a new architecture, namely, Transformer iN Transformer (TNT). Specifically, we regard the local patches (e.g., 16×16) as "visual sentences" and present to further divide them into smaller patches (e.g., 4×4) as "visual words". The attention of each word will be calculated with other words in the given visual sentence with negligible computational costs. Features of both words and sentences will be aggregated to enhance the representation ability. Experiments on several benchmarks demonstrate the effectiveness of the proposed TNT architecture, e.g., we achieve an 81.5% top-1 accuracy on the ImageNet, which is about 1.7% higher than that of the state-of-the-art visual transformer with similar computational cost. The PyTorch code is available at https://github.com/huawei-noah/CV-Backbones, and the MindSpore code is available at https://gitee.com/mindspore/models/tree/master/research/cv/TNT.
In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.
For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2103.00112")
Code
Syntology Ran 16 of 24 code samples harvested from 4 repositories linked to this paper; 8 have no recorded run. Of those that ran: 1 ran · honoured contract; 1 ran · our draft was wrong; 14 ran with no contract checked.
By repository: official repository: 5 samples from 1 repository, 4 ran; community (archive-listed): 19 samples from 3 repositories, 12 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.
Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.
Code Syntology ran Syntology
24 samples harvested; 16 ran; 1 honoured the contract we drafted; 8 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.
Licence: 5 of the 24 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.
Harvested from 4 repositories linked to this paper, official or community; each sample names its own and says which. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.
Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.
Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.
aa47e20b1de49f21 · report
0adf903cee3f68c1 · report
3ab31df137c0d6a7 · report
3b5e96f71824e712 · report
5fc54ab39842a479 · report
e7fd0617316574c2 · report
ae43efde4f9bdb00 · report
81188c67ea536d0b · report
fa83b1a389d93eb9 · report
0f86fae86e577e92 · report
bc8ebba1f2a3f25c · report
3c37926a5a94b20c · report
f10d48901b98d6a7 · report
4cb16ca8e61d759a · report
f61d6e6e8177147a · report
9a4efbdf001d9928 · report
cf4db82cbfb5407c · report
6a49d8dc0841e17c · report
19242d4759c5ee91 · report
950a07c48a64e5ab · report
4b8fa19df5d3871a · report
b506fc7ff0a3b8a4 · report
65876fc080ac5567 · report
1e954f6d1f5902c2 · report
Tasks
Results from the paper archive 2025-07-28
| Task | Dataset | Model | Metric | Value | Rank at snapshot | Leaderboard | Report |
|---|---|---|---|---|---|---|---|
| Fine-Grained Image Classification | Oxford 102 Flowers | TNT-B | Accuracy | 99.0% | #8 of 25 | Archive leaderboard | report |
| Fine-Grained Image Classification | Oxford 102 Flowers | TNT-B | PARAMS | 65.6M | #8 of 25 | Archive leaderboard | report |
| Fine-Grained Image Classification | Oxford-IIIT Pet Dataset | TNT-B | Accuracy | 95.0% | #9 of 15 | Archive leaderboard | report |
| Fine-Grained Image Classification | Oxford-IIIT Pet Dataset | TNT-B | PARAMS | 65.6M | #9 of 15 | Archive leaderboard | report |
| Image Classification | CIFAR-10 | TNT-B | Percentage correct | 99.1 | #15 of 265 | Archive leaderboard | report |
| Image Classification | CIFAR-100 | TNT-B | PARAMS | 65.6M | #21 of 211 | Archive leaderboard | report |
| Image Classification | CIFAR-100 | TNT-B | Percentage correct | 91.1 | #21 of 211 | Archive leaderboard | report |
| Image Classification | ImageNet | TNT-B | Number of params | 65.6M | #380 of 1060 | Archive leaderboard | report |
| Image Classification | ImageNet | TNT-B | Top 1 Accuracy | 83.9% | #380 of 1060 | Archive leaderboard | report |
Ranks are positions in the archive's leaderboards as they stood at the 2025-07-28 snapshot. Results published since then are not among these rows, so a rank here is not a current standing.
Methods
Introduced by this paper: TNT
Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections