CROWNVerification<T, TInput, TOutput>

Models & Types · AiDotNet.AdversarialRobustness.CertifiedRobustness

Implements CROWN (Convex Relaxation based perturbation analysis Of Neural networks) for computing certified robustness bounds.

Implements: ICertifiedDefense<T, TInput, TOutput>

For Beginners

CROWN finds the smallest “safety box” around a prediction where we can guarantee the model’s answer won’t change. It’s more precise than IBP because it uses smarter mathematical approximations.

How It Works

CROWN is a state-of-the-art neural network verification technique that computes tighter certified bounds than IBP by using linear relaxation of non-linear activations. It works by propagating linear upper and lower bounds backward through the network.

Mathematical Foundation: For a ReLU activation σ(x) = max(0, x) with bounds [l, u]:

Case 1: l ≥ 0 (always active): σ(x) = x Case 2: u ≤ 0 (always inactive): σ(x) = 0 Case 3: l < 0 < u (crossing): Use linear relaxation

  • Upper bound: σ(x) ≤ u(x - l)/(u - l)
  • Lower bound: σ(x) ≥ 0 or σ(x) ≥ x (choose tighter)

CROWN propagates these linear bounds backward through the network to get tighter output bounds than IBP’s forward propagation alone.

Constructors

Constructor Summary
CROWNVerification() Initializes a new instance of the CROWNVerification class with default options.
CROWNVerification(CertifiedDefenseOptions<T> options) Initializes a new instance of the CROWNVerification class with specified options.

Methods

Method Summary
CertifiedAccuracyMetrics<T> EvaluateCertifiedAccuracy(TInput[] testData, TOutput[] labels, IFullModel<T, TInput, TOutput> model, T radius)
CertifiedDefenseOptions<T> GetOptions()
CertifiedPrediction<T> CertifyPrediction(TInput input, IFullModel<T, TInput, TOutput> model)
CertifiedPrediction<T>[] CertifyBatch(TInput[] inputs, IFullModel<T, TInput, TOutput> model)
T ComputeCertifiedRadius(TInput input, IFullModel<T, TInput, TOutput> model)
byte[] Serialize()
void Deserialize(byte[] data)
void LoadModel(string filePath)
void Reset()
void SaveModel(string filePath)