Latent Zoning Network: A Unified Principle for Generative Modeling, Representation Learning, and Classification

Zinan Lin, Enshu Liu, Xuefei Ning, Junyi Zhu, Wenyu Wang, Sergey Yekhanin

TL;DR

The Latent Zoning Network (LZN) introduces a unified framework that addresses three core machine learning tasks—generative modeling, representation learning, and classification—using a single mathematical principle. By partitioning a shared Gaussian latent space into distinct "zones" via flow matching, LZN allows different tasks to be expressed simply as combinations of data-specific encoders and decoders. Crucially, the authors demonstrate that training these tasks jointly within a unified space yields powerful cross-task synergies, improving both generation quality and classification accuracy.

What Problem Does This Paper Address?

In modern machine learning, generative modeling, representation learning, and classification are treated as distinct problems requiring entirely different architectures and loss functions. For instance, state-of-the-art image generation relies on diffusion models or autoregressive transformers; representation learning depends on contrastive losses (like CLIP or SimCLR); and classification uses dedicated networks trained with cross-entropy.

This fragmentation complicates machine learning pipelines and prevents models from sharing complementary features across tasks (e.g., contrastive representations often discard the fine-grained details needed for high-quality generation). The authors ask a fundamental question inspired by Occam's Razor: Can a single principle unify all three tasks to simplify pipelines and foster cross-task synergy?

Methods

LZN achieves unification by establishing a shared, continuous Gaussian latent space. Each data type (images, text, labels) is assigned its own encoder and decoder. Machine learning tasks are then framed simply as different paths through these modules. For example, image classification maps an image through the image encoder to the latent space, and then through the label decoder to output a class.

Figure 1: Latent Zoning Network (LZN) connects multiple encoders and decoders through a shared latent space, enabling a wide range of ML tasks via different encoder-decoder combinations or standalone encoders/decoders. The figure illustrates eight example tasks, but more could be supported. Only tasks 1-4 are evaluated in this paper, while the rest are for illustration.

The framework relies on two novel atomic operations:

  1. Latent Computation: To ensure the latent space remains generative, the framework maps data samples to specific "anchor points" using an encoder, and then applies Flow Matching (FM) to expand these points into distinct, disjoint "latent zones." Collectively, these zones are forced to follow a standard Gaussian distribution, making it easy to sample from them for generation tasks while keeping different samples distinct for classification.
  2. Latent Alignment: To translate between different modalities (e.g., matching an image zone to its corresponding text or label zone), the authors introduce a differentiable "soft" approximation technique. This aligns the flow matching trajectories of different encoders midway through training, overcoming the non-differentiable hurdle of discrete anchor assignments.
Figure 3: Training and inference in LZN rely on two atomic operations: (1) Latent computation (§ 2.2.1): Computes latent zones for a data type by encoding sam- ples into anchor points and using flow matching (FM) [54, 51] to partition the latent space. Conversely, any la- tent point can be mapped to a sample via the decoder (not shown). (2) Latent alignment (§ 2.2.2): Aligns latent zones across data types by matching their FM processes. This figure also illustrates the approach for LZN in joint conditional generative modeling and classification (§ 5).

Datasets

The authors evaluated LZN primarily in the image domain using the following standard benchmarks:

  • CIFAR10: Used for unconditional generation, conditional generation, and joint classification tasks.
  • ImageNet: Used to evaluate unsupervised representation learning via downstream linear classification.
  • AFHQ-Cat, CelebA-HQ, and LSUN-Bedroom: High-resolution ($256 \times 256$) image datasets used to test LZN's ability to enhance unconditional generative modeling.

Key Insights and Ideas

  • Cross-Task Synergy is Real: The most exciting finding is that learning to generate images helps classification, and vice versa. When trained jointly on both tasks, LZN achieved better image generation quality (lower FID) and higher classification accuracy than when the tasks were trained in isolation.
  • Inherent Anti-Collapse: Traditional representation learning methods (like contrastive learning) require massive batch sizes or complex architectural tricks to prevent "representation collapse" (where the model maps all inputs to the same output). LZN inherently avoids this because its flow-matching mechanism mathematically forces different samples into distinct, disjoint latent zones.
  • An Elegant Parallel to LLMs: The authors note a striking mathematical parallel between computing latents in LZN and computing attention weights in Large Language Models (LLMs). Both suffer from a quadratic computational cost ($O(n^2)$) relative to sequence length/batch size, suggesting that efficiency optimizations developed for LLMs could directly benefit future LZN scaling.

Key Results

The authors demonstrated LZN's capabilities across three distinct scenarios:

  • Enhancing Existing Generative Models: When integrated as an unsupervised conditioning signal into a state-of-the-art Rectified Flow model, LZN improved the Frechet Inception Distance (FID) on CIFAR10 from 2.76 to 2.59 without altering the core training objective. It also significantly reduced reconstruction errors across all high-resolution datasets.
  • Independent Representation Learning: In an unsupervised setup on ImageNet, a ResNet-50 backbone trained with LZN achieved a 69.5% Top-1 accuracy on downstream linear probing, outperforming seminal self-supervised methods like MoCo (60.2%) and SimCLR (69.3%).
  • Joint Generation and Classification: On CIFAR10, LZN successfully performed class-conditional generation and classification simultaneously, achieving a state-of-the-art classification accuracy of 94.47% for models trained purely on CIFAR10 without external pretraining.

Limitations and Future Work

Despite its promise, LZN faces a few key hurdles:

  • Training Efficiency: Backpropagating through the flow matching trajectories is computationally expensive due to its quadratic complexity relative to batch size. Training the ImageNet representation model required 1,800 hours on 128 A100 GPUs.
  • Standalone Generation Quality: While LZN excels at enhancing existing generative frameworks (like Rectified Flow), using LZN entirely on its own as a standalone generative model currently produces blurry images on complex datasets like CIFAR10.
  • Scaling to Other Modalities: The current experimental scope is limited to images and labels. Extending the framework to handle text-to-image generation or complex multi-modal tasks remains an open direction for future research.

Summary updated

Abstract

Generative modeling, representation learning, and classification are three core problems in machine learning (ML), yet their state-of-the-art (SoTA) solutions remain largely disjoint. In this paper, we ask: Can a unified principle address all three? Such unification could simplify ML pipelines and foster greater synergy across tasks. We introduce Latent Zoning Network (LZN) as a step toward this goal. At its core, LZN creates a shared Gaussian latent space that encodes information across all tasks. Each data type (e.g., images, text, labels) is equipped with an encoder that maps samples to disjoint latent zones, and a decoder that maps latents back to data. ML tasks are expressed as compositions of these encoders and decoders: for example, label-conditional image generation uses a label encoder and image decoder; image embedding uses an image encoder; classification uses an image encoder and label decoder. We demonstrate the promise of LZN in three increasingly complex scenarios: (1) LZN can enhance existing models (image generation): When combined with the SoTA Rectified Flow model, LZN improves FID on CIFAR10 from 2.76 to 2.59-without modifying the training objective. (2) LZN can solve tasks independently (representation learning): LZN can implement unsupervised representation learning without auxiliary loss functions, outperforming the seminal MoCo and SimCLR methods by 9.3% and 0.2%, respectively, on downstream linear classification on ImageNet. (3) LZN can solve multiple tasks simultaneously (joint generation and classification): With image and label encoders/decoders, LZN performs both tasks jointly by design, improving FID and achieving SoTA classification accuracy on CIFAR10. The code and trained models are available at https://github.com/microsoft/latent-zoning-networks. The project website is at https://zinanlin.me/blogs/latent_zoning_networks.html.
BibTeX
@inproceedings{lin2025latent,
  author = {Zinan Lin and Enshu Liu and Xuefei Ning and Junyi Zhu and Wenyu Wang and Sergey Yekhanin},
  title = {{Latent Zoning Network: A Unified Principle for Generative Modeling, Representation Learning, and Classification}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=8KuKSKLott},
}
Figure