AI Verification: Constrained Deep Learning

Version 1.0.2 (7.92 MB) by Antoni Woss
Constrained deep learning is an advanced approach to training deep neural networks by incorporating domain-specific constraints.
11 Downloads
Updated 27 Mar 2024

AI Verification: Constrained Deep Learning Open in MATLAB Online

Constrained deep learning is an advanced approach to training deep neural networks by incorporating domain-specific constraints into the learning process. By integrating these constraints into the construction and training of neural networks, you can guarantee desirable behaviour in safety-critical scenarios where such guarantees are paramount.

This project aims to develop and evaluate deep learning models that adhere to predefined constraints, which could be in the form of physical laws, logical rules, or any other domain-specific knowledge. In the context of AI verification, constrained deep learning provides guarantees that certain desirable properties are present in the trained neural network by design. These desirable properties could include monotonicity, boundedness, and robustness amongst others.

By bringing together the concepts of monotonicity, convexity, and Lipschitz continuity, this repository serves as a comprehensive resource for embedding essential constraints into deep learning models, addressing the complex needs of safety-critical systems and fostering the convergence of theoretical principles with practical AI verification applications.

You can learn more about monotonicity and Lipschitz continuity in the context of aerospace applications in the "Formal Methods Use for Learning Assurance" report from EASA and Collins Aerospace [1].

Get Started

Download or clone this repository to your machine and open it in MATLAB®. Add the conslearn directory and subfolders to the search path. Go to the location of the repository and run the command: addpath(genpath("conslearn")).

Requirements

Examples

The repository contains several introductory, interactive examples as well as longer, real-world use case applications of constrained deep learning in the context of AI verification. In the same directory as the markdown files, you can find the Live Script (MLX) file that you can open in MATLAB and run interactively to work through the example.

Introductory Examples (Short)

Below are links for markdown versions of MATLAB Live Scripts that you can view in GitHub®.

These examples make use of custom training loops and the arrayDatastore object. To learn more, click the links.

Workflow Examples (Long)

  • Dynamical System Modeling Using Convex Neural ODE This example works through the modeling of a dynamical system using a neural ODE, where the underlying dynamics is captured by a fully input convex neural network and the ODE solver uses a convex update method, for example, the Euler method. The example shows how the network is expressive enough to capture nonlinear dynamics and also provides boundedness guarantees on the solution trajectories owing to the convex constraint of the underlying network and ODE solver.

  • Train Fully Convex Neural Networks for CIFAR-10 Image Classification This example shows the expressive capabilities of fully convex networks by obtaining high training accuracy on image classification on the natural image dataset, CIFAR-10.

  • Remaining Useful Life Estimation Using Monotonic Neural Networks This example shows how to guarantee monotonic decreasing prediction on a remaining useful life (RUL) tasks by combining partially and fully monotonic networks. This example looks at predicting the RUL for turbofan engine degradation.

  • Train Image Classification Lipschitz Constrained Networks and Measure Robustness to Adversarial Examples This example shows how Lipschitz continuous constrained networks improve the robustness of neural networks against adversarial attack. In this example, you use formal verification methods to compute the number of robust images in the test set against adversarial perturbation for several networks with decreasing upper bound Lipschitz constants. You find a smaller Lipschitz constant gives a more robust classification network.

Functions

This repository introduces the following functions that are used throughout the examples:

Tests

This repository also contains tests for the software in the conslearn package.

As discussed in [1] (see 3.4.1.5), in certain situations, small violations in the constraints may be admissible. For example, a small violation in monotonicity may be admissible if the non-monotonic behaviour is kept below a pre-defined threshold. In the system tests, you will see examples of tests that incorporate an admissibility constant. This can account for violations owing to floating point error for instance.

Technical Articles

This repository focuses on the development and evaluation of deep learning models that adhere to constraints crucial for safety-critical applications, such as predictive maintenance for industrial machinery and equipment. Specifically, it focuses on enforcing monotonicity, convexity, and Lipschitz continuity within neural networks to ensure predictable and controlled behavior.

By emphasizing constraints like monotonicity, constrained neural networks ensure that predictions of the Remaining Useful Life (RUL) of components behave intuitively: as a machine's condition deteriorates, the estimated RUL should monotonically decrease. This is crucial in applications like aerospace or manufacturing, where an accurate and reliable estimation of RUL can prevent failures and save costs.

Alongside monotonicity, Lipschitz continuity is also enforced to guarantee model robustness and controlled behavior. This is essential in environments where safety and precision are paramount such as control systems in autonomous vehicles or precision equipment in healthcare.

Convexity is especially beneficial for control systems as it inherently provides boundedness properties. For instance, by ensuring that the output of a neural network lies within a convex hull, it is possible to guarantee that the control commands remain within a safe and predefined operational space, preventing erratic or unsafe system behaviors. This boundedness property, derived from the convex nature of the model's output space, is critical for maintaining the integrity and safety of control systems under various conditions.

These technical articles explain key concepts of AI verification in the context of constrained deep learning. They include discussions on how to achieve the specified constraints in neural networks at construction and training time, as well as deriving and proving useful properties of constrained networks in AI verification applications. It is not necessary to go through these articles in order to explore this repository, however, you can find references and more in depth discussion here.

  • AI Verification: Monotonicity - Discussion on fully and partially monotonic neural networks and proveable trends. This article introduces monotonic network architectures and restrictions on weights to guarantee monotonic behaviour.
  • AI Verification: Convexity - Discussion on fully and partially convex neural networks and proveable guarantees of boundedness over hypercubic grids. This article contains proofs on how to prove boundedness properties of a convex neural network on hypercubic grids by analyzing the network and its derivative at the vertices.
  • AI Verification: Lipschitz Continuity - Discussion on Lipschitz continuous neural networks and proveable guarantees of robustness. This article introduce Lipschitz continuity and how to compute an upper bound on the Lipschitz constant for a set of network architectures.

References

Copyright 2024, The MathWorks, Inc.

Cite As

Antoni Woss (2024). AI Verification: Constrained Deep Learning (https://github.com/matlab-deep-learning/constrained-deep-learning), GitHub. Retrieved .

MATLAB Release Compatibility
Created with R2024a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

conslearn

conslearn/+conslearn/+convex

conslearn/+conslearn/+layer

conslearn/+conslearn/+lipschitz

conslearn/+conslearn/+monotonic

examples/convex/classificationCIFAR10

examples/convex/neuralODE

examples/monotonic/RULEstimateUsingMonotonicNetworks

tests/system

tests/system/+util

tests/unit

tests/unit/conslearn/convex

tests/unit/conslearn/layer

tests/unit/conslearn/lipschitz

tests/unit/conslearn/monotonic

examples/convex/classificationCIFAR10

examples/convex/introductory

examples/convex/neuralODE

examples/lipschitz/classificationDigits

examples/lipschitz/introductory

examples/monotonic/RULEstimateUsingMonotonicNetworks

examples/monotonic/introductory

Versions that use the GitHub default branch cannot be downloaded

Version Published Release Notes
1.0.2

Updated File Exchange graphic.

1.0.1

Updated title in File Exchange.

1.0.0

To view or report issues in this GitHub add-on, visit the GitHub Repository.
To view or report issues in this GitHub add-on, visit the GitHub Repository.