Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

torch.cdist works faster than distance_matrix. #30

Merged
merged 1 commit into from
Dec 6, 2021
Merged

Conversation

paining
Copy link

@paining paining commented Nov 5, 2021

and it needs more small gpu-memory.

There is a memory overload in torch.pow(x-y,p).sum()
When I try with this code, I already reserve 8GB and try to allocate another 8GB.

I have a RTX 3080 GPU with 10GB memory.
And when I input big image (3,896,896), distance matrix needs 14.36GB but torch.cdist works well.

It means we can use more large sampling rates by using torch.cdist function.
I can run sampling rate = 0.01 with torch.cdist but I got CUDA out of memory with distance_matrix.


Actual GPU memory usages with MVTec AD.
#19 (comment)

and it needs more small gpu-memory.
@royarahimzadeh
Copy link

Great, I can run with a higher sampling rate too.
I have a problem, not sure if it is related to the current higher sampling rate. I see that the false negative rate is higher than before. Any suggestions for improving?

@paining
Copy link
Author

paining commented Nov 17, 2021

Great, I can run with a higher sampling rate too. I have a problem, not sure if it is related to the current higher sampling rate. I see that the false negative rate is higher than before. Any suggestions for improving?

Humm... That is interesting...
I don't know why the false negative rate become higher.
But as you said, I guess the higher sampling rate makes the high false negative rate too.
I think too many samples decrease the distance between new test features (it may be normal or defect) and sampled features.
Variance of distance become smaller, it makes bigger trade-off problem.

We can see the table 4 in PatchCore paper, 10% sampling rate has higher pixel AUROC and PRO score than 25%.

That is my best guess.....
Another person can give us more clear solution!

@hcw-00 hcw-00 merged commit b61c492 into hcw-00:main Dec 6, 2021
@hcw-00
Copy link
Owner

hcw-00 commented Dec 6, 2021

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants