Real-time Out-of-distribution Detection in Learning-Enabled Cyber-Physical Systems

Feiyang Cai, Xenofon D. Koutsoukos

Abstract

Cyber-physical systems (CPS) greatly benefit by using machine learning components that can handle the uncertainty and variability of the real-world. Typical components such as deep neural networks, however, introduce new types of hazards that may impact system safety. The system behavior depends on data that are available only during runtime and may be different than the data used for training. Out-of-distribution data may lead to a large error and compromise safety. The paper considers the problem of efficiently detecting out-of-distribution data in CPS control systems. Detection must be robust and limit the number of false alarms while being computational efficient for real-time monitoring. The proposed approach leverages inductive conformal prediction and anomaly detection for developing a method that has a well-calibrated false alarm rate. We use variational autoencoders and deep support vector data description to learn models that can be used efficiently compute the nonconformity of new inputs relative to the training set and enable real-time detection of out-of-distribution high-dimensional inputs. We demonstrate the method using an advanced emergency braking system and a self-driving end-to-end controller implemented in an open source simulator for self-driving cars. The simulation results show very small number of false positives and detection delay while the execution time is comparable to the execution time of the original machine learning components.

Introduction

Modern Cyber-Physical Systems (CPS), such as autonomous vehicles and advanced robotics, increasingly rely on Learning-Enabled Components (LECs) like Deep Neural Networks for perception and control. While these models perform exceptionally well on data similar to their training sets, they can fail unpredictably when encountering out-of-distribution (OOD) data—novel conditions such as extreme weather or adversarial attacks that were not represented in the training distribution.

Detecting OOD data is critical for safety-critical systems, as it allows the system to hand over control to a human or switch to a safe fallback mode. However, real-time OOD detection for high-dimensional inputs like camera feeds is challenging. Traditional anomaly detection methods often require massive computational resources or storage, making them unsuitable for the strict latency requirements of moving vehicles. Furthermore, many detectors suffer from high false alarm rates, which can lead to unnecessary system interruptions.

Methodology

The proposed approach builds on Inductive Conformal Anomaly Detection (ICAD), a statistical framework that tests whether a new input conforms to the training data distribution. To achieve real-time performance for high-dimensional images, the authors replace traditional, slow nonconformity measures with fast, learned neural network models:

  1. VAE-based Approach: A Variational Autoencoder (VAE) is trained on normal data. At runtime, the reconstruction error of the input image serves as the nonconformity score.
  2. SVDD-based Approach: A Deep Support Vector Data Description (SVDD) model maps normal inputs into a tight hypersphere in a latent space. The distance of a new input to the center of this hypersphere serves as its nonconformity score.
Block diagram of a learning-enabled control loop for an autonomous vehicle.

To mitigate false alarms caused by transient noise, the authors utilize martingale tests. Since CPS inputs arrive as time-correlated sequences (e.g., video feeds), a martingale can track a sequence of $p$-values over time. If the system encounters a sustained sequence of unusual inputs, the martingale value grows exponentially, triggering an alarm only when the system is confidently facing OOD data.

Experimental Setup

The method was evaluated using the CARLA open-source simulator in two primary scenarios:

  • Advanced Emergency Braking System (AEBS): Trained on 8,160 images, with OOD data generated by manipulating weather and precipitation parameters to create visual conditions unseen during training.
  • Self-driving End-to-end Control (SDEC): Based on a model trained via conditional imitation learning. OOD data consisted of physically realizable adversarial attacks, such as black lines painted on the road designed to hijack the car's steering.

Key Results

The evaluation demonstrated that the proposed method is both efficient and robust. The SVDD-based method executed in just ~2.2 milliseconds, while the VAE-based method took between 18 and 78 ms. Both fit comfortably within the real-time control loops of the simulated vehicles (50–100 ms).

Real-time monitoring of OOD detection metrics, showing p-values and martingale growth upon encountering OOD data.

As shown in the monitoring results, the onset of OOD data (indicated by the red dashed line) leads to a sharp drop in $p$-values and a corresponding exponential rise in the martingale values ($S$ and $\log M$). In the AEBS simulation, the detectors achieved near-zero false positive rates while successfully catching OOD weather conditions. In the SDEC scenario, the method detected 100% of adversarial line-painting attacks, including those that would have otherwise caused a vehicle crash.

Conclusion

This research provides a robust framework for real-time OOD detection in CPS by combining learned nonconformity measures with martingale-based temporal analysis. By leveraging the time-correlated nature of sensor data, the system achieves a well-calibrated false alarm rate and low detection latency. Future work will focus on distinguishing between OOD inputs that lead to catastrophic failures versus those that are benign, as well as testing the framework on real-world physical sensor data.

Summary updated

Abstract

Cyber-physical systems (CPS) greatly benefit by using machine learning components that can handle the uncertainty and variability of the real-world. Typical components such as deep neural networks, however, introduce new types of hazards that may impact system safety. The system behavior depends on data that are available only during runtime and may be different than the data used for training. Out-of-distribution data may lead to a large error and compromise safety. The paper considers the problem of efficiently detecting out-of-distribution data in CPS control systems. Detection must be robust and limit the number of false alarms while being computational efficient for real-time monitoring. The proposed approach leverages inductive conformal prediction and anomaly detection for developing a method that has a well-calibrated false alarm rate. We use variational autoencoders and deep support vector data description to learn models that can be used efficiently compute the nonconformity of new inputs relative to the training set and enable real-time detection of out-of-distribution high-dimensional inputs. We demonstrate the method using an advanced emergency braking system and a self-driving end-to-end controller implemented in an open source simulator for self-driving cars. The simulation results show very small number of false positives and detection delay while the execution time is comparable to the execution time of the original machine learning components.
BibTeX
@inproceedings{cai2020real,
  author = {Feiyang Cai and Xenofon D. Koutsoukos},
  title = {{Real-time Out-of-distribution Detection in Learning-Enabled Cyber-Physical Systems}},
  booktitle = {ICCPS},
  year = {2020},
  url = {https://openreview.net/forum?id=n-VPjV45qS},
}
Figure