AnomalyDetectorLayer<T>
Layers · AiDotNet.NeuralNetworks.Layers
Represents a layer that detects anomalies by comparing predictions with actual inputs.
Inheritance: LayerBase<T> → AnomalyDetectorLayer<T>
Implements: IShapeContract
For Beginners
This layer identifies patterns that don’t match what the network expected.
Think of anomaly detection like this:
- The network learns what “normal” looks like from the data
- This layer compares new inputs to what the network expected to see
- If the actual input is very different from the prediction, it’s flagged as anomalous
- The output is an “anomaly score” between 0 and 1 (higher means more unusual)
For example, in monitoring network traffic, the system might learn normal patterns and then use this layer to alert when unusual activity is detected that might indicate a security breach.
How It Works
The AnomalyDetectionLayer compares the predicted state with the actual state to calculate an anomaly score. This score represents how unexpected or surprising the current input is, given the model’s predictions. Higher scores indicate more anomalous (unexpected) inputs.
Constructors
| Constructor | Summary |
|---|---|
AnomalyDetectorLayer(int inputSize, double anomalyThreshold, int historyCapacity, double smoothingFactor, IEngine engine) |
Initializes a new instance of the AnomalyDetectorLayer class. |
Properties
| Property | Summary |
|---|---|
bool SupportsTraining { get; } |
The computation engine (CPU or GPU) for vectorized operations. |
Methods
| Method | Summary |
|---|---|
Dictionary<string, double> GetAnomalyStatistics() |
Gets the statistical properties of recent anomaly scores. |
IReadOnlyList<OutputAxisContract> OutputAxesFor(int inputRank) |
|
T GetAnomalyScore() |
Gets the current anomaly score. |
bool IsAnomaly() |
Determines if the current input is anomalous based on the anomaly score. |
void ResetState() |
Resets the internal state of the layer. |