Recursive Vision Transformers X

Recursive Vision Transformers

What if a Vision Transformer had just one block, applied over and over until its representation stops changing? I tried to turn a weight-tied ViT into a model that converges to a fixed point, so that its depth becomes something it computes rather than something we fix in advance.

Diagram: image patches are embedded, passed repeatedly through one shared ViT block with the input injected at every step, and the fixed point is classified
One shared block, iterated until the token state settles.

The idea

A standard ViT stacks a dozen or so blocks, each with its own weights. A recursive ViT, like the Universal Transformer, reuses the same block at every step. This gives you as much depth as you like without adding parameters, and it raises a natural question: if we can run the block as many times as we want, can we run it until the answer stops changing?

The problem

Simply sharing weights is not enough. A recursive model trained for, say, 12 iterations works well at 12, but if you let it run longer, its internal state drifts and its predictions start to change. More computation does not automatically mean better answers, and the number of iterations quietly becomes another hyperparameter.

What we actually want is for the iteration to converge to a fixed point:

zt+1 = Fθ(zt, x)  →  z* = Fθ(z*, x)

That is also the assumption behind Deep Equilibrium Models (DEQs). If a real equilibrium exists, you can find it with a root solver instead of naive unrolling, and train with implicit differentiation instead of storing every intermediate step, which can save a lot of memory. But all of this only holds if the model actually converges.

What I tried

On Tiny ImageNet (200 classes), I explored several ways to make the iteration stable:

With these changes, the model finally reached a fixed point: instead of drifting, its state settled as the iterations went on.

A glimpse of the results

Here is one comparison between a regular ViT and my recursive model (called Transit in the plots). For the ViT, the x-axis is the number of blocks; for Transit, it is the number of times the single shared block is applied.

Validation accuracy versus depth or iterations: Transit matches or beats ViT at every depth, peaking around 0.51 at 12 iterations
Validation accuracy vs. depth (ViT) or iterations (Transit).
Validation accuracy versus number of parameters: Transit stays at about 0.65 million parameters while ViT grows to over 8 million
The same runs, plotted against the number of parameters.

With the same amount of computation, Transit is as accurate as the ViT or slightly more so, peaking at about 51% at 12 iterations compared with 49% for a 12-block ViT. It does this with roughly 0.65M parameters, against more than 5M for the ViT. A variant that iterates 3 distinct blocks 4 times each (d:3, i:4) did best overall, at about 52% with around 1.5M parameters.

What comes next

← Back to My Research