alibi_detect.od.pytorch.mahalanobis module
- class alibi_detect.od.pytorch.mahalanobis.MahalanobisTorch(min_eigenvalue=1e-06, device=None)[source]
Bases:
TorchOutlierDetector
- __init__(min_eigenvalue=1e-06, device=None)[source]
PyTorch backend for Mahalanobis detector.
- Parameters:
min_eigenvalue (
float
) – Eigenvectors with eigenvalues below this value will be discarded.device (
Union
[Literal
[‘cuda’, ‘gpu’, ‘cpu’],device
,None
]) – Device type used. The default tries to use the GPU and falls back on CPU if needed. Can be specified by passing either'cuda'
,'gpu'
,'cpu'
or an instance oftorch.device
.
- ensemble = False
- forward(x)[source]
Detect if x is an outlier.
- Parameters:
x (
Tensor
) – torch.Tensor with leading batch dimension.- Return type:
Tensor
- Returns:
torch.Tensor of
bool
values with leading batch dimension.- Raises:
ThresholdNotInferredException – If called before detector has had infer_threshold method called.