Conditional Variational Capsule Network for Open Set Recognition

Yunrui Guo, Guglielmo Camporese, Wenjing Yang, Alessandro Sperduti, Lamberto Ballan

Introduction

Standard deep learning classifiers typically operate under a "closed set" assumption, where all test samples are expected to belong to one of the predefined training categories. In real-world scenarios, however, models frequently encounter "unknown" samples from categories never seen during training. Open Set Recognition (OSR) addresses this by requiring models to accurately classify known categories while simultaneously identifying and rejecting unknown inputs. The primary challenge in OSR is structuring a latent feature space such that known classes are represented by compact, well-separated clusters, leaving sufficient "empty space" to detect outliers as unknowns.

Methodology

The proposed Conditional Variational Capsule Network (CVAECapOSR) integrates the structural advantages of Capsule Networks with the probabilistic framework of Conditional Variational Autoencoders (CVAEs). The architecture is divided into three functional stages:

  1. Encoding Stage: Input features are extracted via a backbone (e.g., ResNet) and processed through a Capsule Network. Unlike traditional scalar neurons, capsules output vectors that encode hierarchical spatial relationships and object properties, leading to more robust feature representations.
  2. Contrastive Variational Stage: This stage maps features to a latent space where each known class is assigned a unique Gaussian prior. A contrastive loss is employed to minimize intra-class variance (pulling samples toward their respective class centers) while maximizing inter-class distance (pushing samples away from other class centers). This creates distinct "islands" of known data.
  3. Decoding Stage: A decoder reconstructs the input image from the latent vector $z$, ensuring that the latent space preserves essential generative information.
The CVAECapOSR architecture, featuring an encoder, Capsule Network, latent sampling with class-specific priors, and a reconstruction decoder.

During inference, the model calculates the distance between a new sample's latent representation and the nearest class Gaussian. Samples exceeding a predefined distance threshold are rejected as "unknown."

Experimental Setup

The model was evaluated across several standard benchmarks with varying degrees of "openness":

  • MNIST, SVHN, and CIFAR-10: Configured with 6 known and 4 unknown classes.
  • CIFAR+10 and CIFAR+50: 4 known classes from CIFAR-10 against 10 or 50 unknown classes from CIFAR-100.
  • TinyImageNet: A complex setup with 20 known and 180 unknown classes.
  • Out-of-Distribution (OOD) Testing: Models trained on MNIST were tested against Omniglot and synthetic noise to evaluate extreme rejection capabilities.

Results and Discussion

CVAECapOSR achieved state-of-the-art performance across nearly all tested benchmarks. On CIFAR-10, the model reached an AUROC of 0.835, significantly surpassing previous methods like CROSR (0.699) and C2AE (0.711). On the more difficult TinyImageNet dataset, it achieved an AUROC of 0.715, a notable improvement over prior techniques that often failed to exceed 0.60.

The Impact of Capsule Networks

A critical finding of the ablation studies was the superiority of Capsule Networks over standard scalar neurons for OSR. Replacing fully connected layers with capsules resulted in an AUROC increase of up to +0.344 for unknown detection. As shown in the t-SNE visualizations, capsules facilitate the formation of much tighter and more distinct clusters for known classes compared to standard neurons, which produce more overlapping and diffuse representations.

t-SNE visualization comparing latent space organization between (a) CVAECapOSR with Capsules and (b) CVAECapOSR with Standard Neurons.

The model also demonstrated high robustness; when trained on MNIST and presented with random noise, it achieved a near-perfect rejection AUROC of 0.982.

Conclusion and Future Work

CVAECapOSR effectively addresses the open set recognition problem by combining contrastive learning, class-specific Gaussian priors, and the representational power of Capsule Networks. While the model sets new performance benchmarks, future research is needed to address hyperparameter sensitivity and scalability to datasets with thousands of classes. Additionally, improving discrimination between extremely similar known and unknown categories remains an open challenge.

Summary updated

BibTeX
@inproceedings{guo2021conditional,
  author = {Yunrui Guo and Guglielmo Camporese and Wenjing Yang and Alessandro Sperduti and Lamberto Ballan},
  title = {{Conditional Variational Capsule Network for Open Set Recognition}},
  booktitle = {IEEE/CVF International Conference on Computer Vision},
  year = {2021},
  doi = {10.1109/iccv48922.2021.00017},
}
Figure