ViTCAE: ViT-based Class-conditioned Autoencoder

Vahid Jebraeeli, Hamid Krim, Derya Cansever · DOI

Abstract

Vision Transformer (ViT) based autoencoders often underutilize the global Class token and employ static attention mechanisms, limiting both generative control and optimization efficiency. This paper introduces ViTCAE, a framework that addresses these issues by re-purposing the Class token into a generative linchpin. In our architecture, the encoder maps the Class token to a global latent variable that dictates the prior distribution for local, patch-level latent variables, establishing a robust dependency where global semantics directly inform the synthesis of local details. Drawing inspiration from opinion dynamics, we treat each attention head as a dynamical system of interacting tokens seeking consensus. This perspective motivates a convergence-aware temperature scheduler that adaptively anneals each head's influence function based on its distributional stability. This process enables a principled head-freezing mechanism, guided by theoretically-grounded diagnostics like an attention evolution distance and a consensus/cluster functional. This technique prunes converged heads during training to significantly improve computational efficiency without sacrificing fidelity. By unifying a generative Class token with an adaptive attention mechanism rooted in multi-agent consensus theory, ViTCAE offers a more efficient and controllable approach to transformer-based generation.

Introduction

Vision Transformers (ViTs), particularly when used as Masked Autoencoders (MAEs), have revolutionized computer vision. However, standard ViT designs rely on two major unchallenged assumptions that limit their generative capabilities and efficiency. First, the global Class (CLS) token is typically treated as a passive feature pooler that absorbs image semantics without an explicit role in guiding generation. Second, the entropy of attention heads is usually governed by a fixed softmax temperature, leading to wasted computation on heads that have already converged.

ViTCAE addresses these limitations by transforming the CLS token into a powerful generative controller and viewing attention heads through the lens of "opinion dynamics." This approach introduces an adaptive temperature scheduler that automatically freezes converged attention heads, boosting both generation quality and training efficiency.

Architecture and Methodology

The ViTCAE framework introduces several architectural and training innovations to enhance the generative capacity of transformers.

Input Processing and Tokenization

The model begins by processing an RGB input image $X$ into stacked and flattened patches $X_F$. A class token is concatenated to the embedded patches, and a learnable position matrix is added to form the input $X_{in}$, as shown below.

Input processing and tokenization in ViTCAE.

Hierarchical Class-Conditioned VAE

The encoder maps the CLS token to a global latent variable, which acts as a prior for local, patch-level latent variables. The decoder then uses this global latent to actively guide patch reconstruction via Feature-wise Linear Modulation (FiLM). This ensures that high-level global semantics directly inform the synthesis of fine, local details.

Attention as Opinion Dynamics

Drawing inspiration from physics and sociology, ViTCAE models the self-attention mechanism as a multi-agent system where tokens are "agents" seeking consensus. Each attention head is given a learnable temperature. The model tracks the "attention evolution distance" (using a 1-Wasserstein metric) between epochs to monitor convergence.

The self-attention mechanism highlighting the interaction between patch tokens and the class token.

If a head's attention distribution stops drifting—meaning the tokens have reached a "consensus"—the head is considered converged. Its parameters are then frozen to save compute. This principled head-freezing mechanism allows for significant computational savings during the backward pass of training.

Experimental Results

The model was evaluated on standard benchmarks including CIFAR-10, CelebA (64×64), and Tiny ImageNet.

Performance and Efficiency

The adaptive temperature control consistently improved classification accuracy over baselines. Most notably, it achieved an 89.67% accuracy on CelebA (up from 81.91%) and 92.87% on Tiny ImageNet (up from 85.33%). Furthermore, by dynamically freezing converged attention heads, ViTCAE achieves up to 25% FLOP savings during training with no loss in reconstruction fidelity.

Generative Quality

Qualitatively, ViTCAE excels at image reconstruction, plausible inpainting of heavily masked inputs, and unconditional image generation. The structured latent space allows for smooth semantic interpolations, such as transitioning facial expressions or hair colors in the CelebA dataset, demonstrating a robust understanding of global image semantics.

Conclusion

ViTCAE demonstrates that the CLS token can be a generative linchpin and that framing self-attention as "opinion dynamics" provides a rigorous way to optimize transformer training. While current experiments are limited to lower resolutions, future work will explore scaling this architecture to higher-resolution images and applying the framework to natural language processing and multimodal tasks.

Summary updated

Abstract

Vision Transformer (ViT) based autoencoders often underutilize the global Class token and employ static attention mechanisms, limiting both generative control and optimization efficiency. This paper introduces ViTCAE, a framework that addresses these issues by re-purposing the Class token into a generative linchpin. In our architecture, the encoder maps the Class token to a global latent variable that dictates the prior distribution for local, patch-level latent variables, establishing a robust dependency where global semantics directly inform the synthesis of local details. Drawing inspiration from opinion dynamics, we treat each attention head as a dynamical system of interacting tokens seeking consensus. This perspective motivates a convergence-aware temperature scheduler that adaptively anneals each head's influence function based on its distributional stability. This process enables a principled head-freezing mechanism, guided by theoretically-grounded diagnostics like an attention evolution distance and a consensus/cluster functional. This technique prunes converged heads during training to significantly improve computational efficiency without sacrificing fidelity. By unifying a generative Class token with an adaptive attention mechanism rooted in multi-agent consensus theory, ViTCAE offers a more efficient and controllable approach to transformer-based generation.

Empirical ResultsBrowse all benchmarks →

BenchmarkMethodMetricScoreProtocol / Evidence
TinyImageNet · Tiny ImageNetViTCAE, TAAcc.92.87%Temperature Adjustment control-strategy comparison; evaluation split not stated.
Source quote
L289: Tiny ImageNet │ TA (Ours) │ 4 │ 196 │ 92.87
TinyImageNet · Tiny ImageNetBaseline (without control)Acc.85.33%Temperature Adjustment control-strategy comparison; evaluation split not stated.
Source quote
L290: Tiny ImageNet │ Baseline │ 12 │ 196 │ 85.33 [0.3em]
CIFAR-10ViTCAE, TAAcc.82.33%Temperature Adjustment control-strategy comparison; evaluation split not stated.
Source quote
L292: CIFAR-10 │ TA (Ours) │ 0 │ 60 │ 82.33
CIFAR-10Baseline (without control)Acc.79.01%Temperature Adjustment control-strategy comparison; evaluation split not stated.
Source quote
L293: CIFAR-10 │ Baseline │ 4 │ 60 │ 79.01 [0.3em]
CelebA FaceViTCAE, TAAcc.89.67%Temperature Adjustment control-strategy comparison; evaluation split not stated.
Source quote
L295: CelebA Face │ TA (Ours) │ 3 │ 138 │ 89.67
CelebA FaceBaseline (without control)Acc.81.91%Temperature Adjustment control-strategy comparison; evaluation split not stated.
Source quote
L296: CelebA Face │ Baseline │ 8 │ 138 │ 81.91
BibTeX
@misc{jebraeeli2025vitcae,
  author = {Vahid Jebraeeli and Hamid Krim and Derya Cansever},
  title = {{ViTCAE: ViT-based Class-conditioned Autoencoder}},
  year = {2025},
  eprint = {2509.16554},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2509.16554},
}
Figure