[Paper Review] The Nuts and Bolts of Adopting Transformer in GANs
This paper proposes STransGAN, a Transformer-based GAN framework that achieves state-of-the-art performance in high-fidelity image synthesis by incorporating feature locality via Swin-like blocks, eliminating harmful residual connections in discriminators, and using skip-projection and conditional normalization to preserve class information. It achieves SOTA FID of 2.03 on CelebA and 4.84 on FFHQ-256, demonstrating the first successful conditional Transformer GAN.
Transformer becomes prevalent in computer vision, especially for high-level vision tasks. However, adopting Transformer in the generative adversarial network (GAN) framework is still an open yet challenging problem. In this paper, we conduct a comprehensive empirical study to investigate the properties of Transformer in GAN for high-fidelity image synthesis. Our analysis highlights and reaffirms the importance of feature locality in image generation, although the merits of the locality are well known in the classification task. Perhaps more interestingly, we find the residual connections in self-attention layers harmful for learning Transformer-based discriminators and conditional generators. We carefully examine the influence and propose effective ways to mitigate the negative impacts. Our study leads to a new alternative design of Transformers in GAN, a convolutional neural network (CNN)-free generator termed as STrans-G, which achieves competitive results in both unconditional and conditional image generations. The Transformer-based discriminator, STrans-D, also significantly reduces its gap against the CNN-based discriminators.
Motivation & Objective
- To address the challenges of adopting Transformers in GANs for high-fidelity image generation, where prior attempts failed due to instability and poor performance.
- To investigate why standard Transformer designs—successful in classification—underperform in GANs, especially in discriminators and conditional generators.
- To identify and resolve key architectural pitfalls, such as harmful residual connections and ineffective conditional injection in self-attention mechanisms.
- To develop a CNN-free generator (STrans-G) and a competitive discriminator (STrans-D) that close the performance gap with CNN-based GANs.
- To establish practical, empirically validated design principles—'nuts and bolts'—for building effective Transformer-based GANs.
Proposed method
- Introduces Swin-like local attention blocks to inject inductive bias for feature locality, replacing global self-attention in standard Transformers.
- Replaces standard residual connections in self-attention layers with skip-projection layers to prevent information flow domination and improve training stability in discriminators.
- Proposes AdaNorm-T, a conditional normalization strategy that injects class labels into the main trunk of the generator rather than the residual path, ensuring conditional information is preserved.
- Employs relative positional encoding and local window partitioning to reduce computational cost and improve feature communication in high-resolution settings.
- Uses a modified training protocol with differentiable data augmentation and careful normalization scheduling to stabilize training.
- Employs ablation studies and norm ratio analysis to validate design choices, particularly the negative impact of residual connections in discriminators.
Experimental results
Research questions
- RQ1Why do standard Transformer architectures, effective in image classification, underperform when directly applied in GANs for image generation?
- RQ2How does feature locality influence the performance of Transformers in GAN-based image synthesis, and what is the optimal way to implement it?
- RQ3Why do residual connections in self-attention layers harm the training and performance of Transformer-based discriminators and conditional generators?
- RQ4What is an effective strategy for injecting conditional class information into a Transformer-based generator without it being bypassed by residual shortcuts?
- RQ5Can a CNN-free generator and a competitive discriminator be designed using Transformers to match or exceed the performance of CNN-based GANs?
Key findings
- The Swin layer with local attention outperforms global self-attention and other localized attention mechanisms, achieving the best FID of 2.03 on CelebA and 4.84 on FFHQ-256.
- Residual connections in self-attention layers dominate information flow in discriminators, causing sub-layers to be bypassed and degrading performance, which is mitigated by replacing them with skip-projection layers.
- Injecting conditional information into the residual path of the generator leads to poor performance due to shortcut dominance; injecting it into the main trunk via AdaNorm-T improves inception score from 10.14 to 11.62 on CIFAR10.
- The proposed STrans-G generator achieves competitive FID of 4.84 on FFHQ-256 and 2.03 on CelebA, demonstrating the first successful conditional Transformer GAN.
- The STrans-D discriminator significantly reduces the performance gap against CNN-based discriminators, showing improved stability and quality.
- Ablation studies confirm that the choice of normalization layers and architectural configuration (e.g., config-c with end-of-block AdaNorm) is critical for avoiding mode collapse and achieving high-quality generation.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.