ORippler / gaussian-ad-mvtec

Code underlying our publication "Modeling the Distribution of Normal Data in Pre-Trained Deep Features for Anomaly Detection" at ICPR2020
GNU Affero General Public License v3.0
98 stars 17 forks source link

about mahalanobis_distance #6

Open ShuaiLYU opened 1 year ago

ShuaiLYU commented 1 year ago

Hi, May I 'd like ask a question ? If I have multiple gaussion distributions and a data point x , I want to judge which distribution the x belongs to and calcualate the distance. The intuition is calculating the mahalanobis distances between x and the multiple gaussion distributions folllowed by a argmin operation. is it make sense and how to achieve it by using a quick matrix operation ?

I guess It is kind of like GMM based on mahalanobis_distance

SimplicityApks commented 1 year ago

Hi, yes I'd say that intuitively makes sense. The question you ask there is more generally "how do I efficiently get the index of the gaussian in a gaussian mixture model which likely generated my sample(s)". With max likelihood estimation you directly arrive at the minimum Mahalanobis distance. For quick matrix operation, depending on the number of times you run this and the number of samples you want to answer this for in parallel, just calling the current implementation of mahalanobis_distance iteratively for each mixture should not be too slow.

There is some possibility to optimize, but since each mixture has a different covariance matrix, formulating this in a single torch.einsum call like done in our implementation here would be difficult I suppose.

Leonardo0325 commented 1 year ago

Hello, I would like to ask a question. Now I have found that the Gaussian distribution at certain points exhibits a double Gaussian distribution, and there may be deviations when calculating the mean and covariance. I would like to distinguish the channels that conform to the double Gaussian distribution, and then calculate the minimum Mahalanobis distance separately from the two distributions. Do you have any ideas about this?