Learning Representations of Sets through Optimized Permutations

Yan Zhang, Jonathon S. Hare, Adam Prügel-Bennett

The Challenge of Set Representation

In machine learning, many inputs are naturally "sets"—collections of items where the order doesn't matter, such as a cloud of 3D points, a list of objects in a photo, or a handful of numbers. Standard neural networks, however, are designed to process ordered data.

To handle unordered sets, researchers typically rely on "reduction" operations, like summing or taking the maximum of all element vectors. While this ensures the network's output remains invariant regardless of the input order, it creates a massive information bottleneck. For instance, a set of 100 high-dimensional vectors is squeezed into just one, crushing the rich relational data between elements.

This paper introduces a Permutation-Optimisation (PO) module, a differentiable layer that learns to "sort" set elements into a sequence or grid. By transforming an unordered set into a structured sequence, the model can leverage powerful sequential architectures (like LSTMs) while maintaining permutation invariance.

The Permutation-Optimisation Module

Instead of using a fixed, hardcoded rule to sort elements, the PO module learns to optimize a permutation matrix during the network's forward pass.

Permutation-Optimisation Pipeline

The process relies on several key steps:

  1. Pairwise Comparisons: The model uses a small neural network to compare every pair of elements $(x_i, x_j)$ in the set, generating an "ordering cost." This cost matrix tells the model whether element $i$ should likely come before element $j$.
  2. Differentiable Sorting: Because discrete sorting operations are not differentiable, the authors relax the problem. They treat the permutation as a continuous "doubly-stochastic" matrix (where rows and columns sum to 1) using the Sinkhorn operator.
  3. Optimization in the Forward Pass: The module performs a few steps of gradient descent inside the forward pass to minimize the total ordering cost. Because this optimization process is unrolled, the entire module remains differentiable and can be trained end-to-end.
  4. Sequence Processing: Once the set is "sorted" into a sequence, it is fed into a standard Recurrent Neural Network (LSTM). This allows the model to capture complex relationships between elements that simple pooling would miss.

Key Insights

  • Relational over Absolute: Previous attempts at learnable permutations (like the "LinAssign" baseline) tried to assign elements to absolute positions. This paper argues that pairwise relations (e.g., "is $A$ bigger than $B$?") are much more powerful, allowing the model to generalize to different set sizes and values.
  • The "Proper" Gradient Trick: The authors found that a standard gradient update on the Sinkhorn layer often vanishes. They introduced an alternative update rule that ignores a specific term in the chain rule. While counter-intuitive, it effectively "nudges" the model toward valid permutations much more efficiently.
  • Implicit Supervision: The model doesn't always need to be told the "right" order. In complex tasks, the model learns an internal sorting strategy that makes it easier for the subsequent LSTM to extract the answer, even when no "ground truth" order exists.

Experimental Results

The model was evaluated across four distinct tasks, achieving state-of-the-art results:

  • Number Sorting: On a toy task of sorting lists of random numbers, the PO module sorted sets of up to 1,024 numbers perfectly, even on unseen number ranges. Previous models like Ptr-Net began failing at just 5 elements.
  • Image Mosaics: The model was tasked with re-assembling shuffled image tiles from MNIST, CIFAR10, and ImageNet ($64 \times 64$) back into their original grid.
Mosaic Reconstruction Results

As shown in the results above, the PO-LA (Linear Assignment) variant significantly outperformed existing methods in putting shuffled images back together, particularly on complex datasets like ImageNet.

  • Implicit Mosaic Classification: The model successfully learned to arrange image tiles to help a pre-trained ResNet-18 classifier recognize objects, without explicit supervision on the correct arrangement.
  • Visual Question Answering (VQA): By processing sets of detected object bounding boxes, adding the PO module to the state-of-the-art Bilinear Attention Network (BAN) improved accuracy by 0.37% overall on the VQA v2 dataset. It particularly excelled in the "Number" category, improving counting capabilities.

Limitations and Future Work

While powerful, the PO module has limitations. The primary drawback is its $O(N^3)$ time complexity relative to the set size $N$, caused by matrix multiplications in the optimization loop. This makes it difficult to scale to massive sets like large 3D point clouds. Additionally, because the optimization problem is non-convex, the gradient descent might occasionally get stuck in a sub-optimal local minimum. Future work may explore more sophisticated cost functions to scale these permutations to higher-dimensional structures and lattices.

Summary updated

BibTeX
@inproceedings{zhang2019learning,
  author = {Yan Zhang and Jonathon S. Hare and Adam Prügel-Bennett},
  title = {{Learning Representations of Sets through Optimized Permutations}},
  booktitle = {International Conference on Learning Representations},
  year = {2019},
  url = {https://openreview.net/forum?id=VaP7XStBM4Z},
}
Figure