DirectionAlignmentInspector<T>

Models & Types · AiDotNet.FederatedLearning.BackdoorDefense

Direction Alignment Inspector — detects backdoor attacks via gradient direction analysis.

Inheritance: FederatedLearningComponentBase<T> → DirectionAlignmentInspector<T>

Implements: IBackdoorDetector<T>

For Beginners

In normal training, all clients push the model in roughly the same direction. A backdoor attacker pushes in a different direction for certain parts of the model (the parts that encode the trigger). By checking whether each client’s “push direction” aligns with the majority, we can identify suspicious clients.

How It Works

This detector identifies backdoor attacks by analyzing the alignment between each client’s update direction and the “honest” consensus direction. Backdoor updates tend to have anomalous gradient directions that point away from the clean learning direction, particularly in specific parameter subspaces corresponding to the trigger-target mapping.

Reference: Xu et al. (2025), “Detecting Backdoor Attacks in Federated Learning via Direction Alignment Inspection” (CVPR 2025).

Constructors

Constructor Summary
DirectionAlignmentInspector(int numSubspaces, double alignmentThreshold) Creates a new Direction Alignment Inspector.

Properties

Property Summary
string DetectorName { get; }

Methods

Method Summary
Dictionary<int, Vector<T>> FilterMaliciousUpdates(Dictionary<int, Vector<T>> clientUpdates, Vector<T> globalModel, double suspicionThreshold)
Dictionary<int, double> DetectSuspiciousUpdates(Dictionary<int, Vector<T>> clientUpdates, Vector<T> globalModel)