Efficient Generation of Structured Objects with Constrained Adversarial Networks

Luca Di Liello, Pierfrancesco Ardino, Jacopo Gobbi, Paolo Morettin, Stefano Teso, Andrea Passerini

Generative Adversarial Networks (GANs) have revolutionized image generation, but they notoriously struggle with structured objects that must adhere to "hard" rules. For example, a generated molecule is useless if it violates the laws of chemistry, and a Super Mario Bros. level is a failure if the player cannot actually reach the goal or if the pipes are broken.

Standard GANs attempt to learn these rules implicitly from data. However, if the training data is limited or noisy, the GAN often fails to capture the underlying logic. Previous attempts to fix this usually involved "rejection sampling" (throwing away bad samples) or expensive optimization steps during generation, both of which make the model slow and inefficient for real-time use.

To bridge the gap between deep generative models and symbolic logic, researchers have introduced Constrained Adversarial Networks (CANs). CANs embed hard structural constraints directly into the GAN training process, learning to generate valid complex objects without requiring any extra computational overhead during inference.

The Methodology: Semantic Loss and Throwaway Circuits

CANs modify the standard GAN objective function by adding a penalty term based on Semantic Loss (SL).

Comparison of loss landscapes, including Semantic Loss (SL) used in CANs.
  1. Semantic Loss: This loss function measures the "disagreement" between the generator's output and a set of predefined logical constraints. It treats the generator's output as a probability distribution over possible structures and penalizes the model proportionally to the probability mass it assigns to invalid structures.
  2. Knowledge Compilation: To make this loss differentiable and efficient to calculate during training, the authors use Sentential Decision Diagrams (SDDs). These specialized data structures compile complex logical formulas into a polynomial-like circuit.
  3. The "Throwaway" Circuit: Crucially, the logical circuit is only used during training. Once the generator has learned to respect the constraints, the circuit is discarded. At inference time, generating a valid object is just a standard, lightning-fast forward pass through the neural network.
  4. Hybrid Constraints: For constraints that are too complex for pure logic (like "is this map reachable?"), the authors use an embedding function—a small neural network—to map the output to a space where the constraint can be represented more compactly.

Key Applications and Results

The researchers evaluated CANs on two primary domains: Super Mario Bros. level generation and molecular graph generation.

Super Mario Bros. Level Generation

Using the Video Game Level Corpus (VGLC), the model was tested on its ability to generate valid "pipes" (which have specific structural rules) and "playable" maps (which require a continuous path from start to finish).

Example of a Super Mario Bros. level generated by a CAN, demonstrating valid pipe structures.
  • Mario Pipes: CANs nearly doubled the validity of generated pipes compared to a standard GAN (83.2% vs 47.6%) while maintaining the exact same inference speed (<40ms).
  • Playability: In complex levels, CANs achieved playability rates (71.6%) comparable to evolutionary search methods (65.9%) but were thousands of times faster at generating new levels (milliseconds vs. minutes).

Molecule Generation

The researchers applied their method to the MolGAN architecture to generate molecular graphs that satisfy chemical validity and optimize for properties like druglikeness (QED) and solubility (logP). When combined with reinforcement learning, CANs significantly improved the diversity and chemical quality of generated molecules. For instance, the diversity score jumped from 91.0 to 98.8 when the semantic loss was active.

Insights and Limitations

By baking logic into the weights of the generator during training, CANs provide the benefits of symbolic reasoning at the speed of a standard deep learning model. Furthermore, the semantic loss acts as a regularizer that helps mitigate mode collapse, forcing the generator to explore different valid configurations rather than repeating the same output.

However, the approach is not without limitations:

  • The Compilation Bottleneck: While inference is fast, the "offline" step of compiling logical constraints into SDDs can be computationally expensive for extremely large or complex rule sets.
  • Constraint Specification: The user must still be able to formally define the constraints as logical formulas. If a constraint is "fuzzy" or hard to write down, CANs are harder to apply.
  • Vanishing Features: If a constraint is too difficult to satisfy, the generator might learn to simply not generate that feature at all (e.g., generating a Mario level with no pipes to avoid creating "broken" pipes). While mitigated with a "bootstrap" training phase, it remains a delicate balancing act.

Summary updated

BibTeX
@inproceedings{liello2020efficient,
  author = {Luca Di Liello and Pierfrancesco Ardino and Jacopo Gobbi and Paolo Morettin and Stefano Teso and Andrea Passerini},
  title = {{Efficient Generation of Structured Objects with Constrained Adversarial Networks}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2020},
}
Figure