# Linear Semantics in Generative Adversarial Networks

Source: [Linear Semantics in Generative Adversarial Networks](<https://www.sota2.com/research/paper/68fa69b21e209131cea237e5>)

Collection index: [llms.txt](<https://www.sota2.com/research/llms.txt>)

Data updated: 2026-01-04T05:05:14.136Z

Authors: Jianjin Xu, Changxi Zheng

Published: 2021-04-01T14:18:48.000Z

## Abstract

Generative Adversarial Networks (GANs) are able to generate high-quality images, but it remains difficult to explicitly specify the semantics of synthesized images. In this work, we aim to better understand the semantic representation of GANs, and thereby enable semantic control in GAN's generation process. Interestingly, we find that a well-trained GAN encodes image semantics in its internal feature maps in a surprisingly simple way: a linear transformation of feature maps suffices to extract the generated image semantics. To verify this simplicity, we conduct extensive experiments on various GANs and datasets; and thanks to this simplicity, we are able to learn a semantic segmentation model for a trained GAN from a small number (e.g., 8) of labeled images. Last but not least, leveraging our findings, we propose two few-shot image editing approaches, namely Semantic-Conditional Sampling and Semantic Image Editing. Given a trained GAN and as few as eight semantic annotations, the user is able to generate diverse images subject to a user-provided semantic layout, and control the synthesized image semantics. We have made the code publicly available.

## Recorded benchmark results

A research result applies to its stated dataset, split, metric and evaluation configuration. Compare like-for-like settings, preserve the metric's unit and direction, and distinguish paper-reported results from independent reproduction. The best result recorded here is not a claim of exhaustive, current global coverage.

- [Semantic Image Generation on Bedroom StyleGAN2 (test)](<https://www.sota2.com/research/sota/semantic-image-generation-on-bedroom-stylegan2-test.md>): Semantic Image Generation; Bedroom StyleGAN2 (test); Semantic Accuracy: 22.3.

- [Semantic Image Generation on FFHQ StyleGAN2 (test)](<https://www.sota2.com/research/sota/semantic-image-generation-on-ffhq-stylegan2-test.md>): Semantic Image Generation; FFHQ StyleGAN2 (test); Semantic Accuracy: 40.

- [Semantic Image Generation on Church StyleGAN2 (test)](<https://www.sota2.com/research/sota/semantic-image-generation-on-church-stylegan2-test.md>): Semantic Image Generation; Church StyleGAN2 (test); Semantic Accuracy: 20.4.

## Original sources and implementation

[Original paper](<https://arxiv.org/abs/2104.00487>)

[PDF](<https://arxiv.org/pdf/2104.00487.pdf>)

[Implementation](<https://github.com/AtlantixJJ/LinearGAN>)
