AlessioGalluccio / FastFlow

an implementation of the architecture of FastFlow (Jiawei Yu et al.)
MIT License
40 stars 13 forks source link

calculate anomaly score waste lots of GPU memory? #9

Closed letmejoin closed 2 years ago

letmejoin commented 2 years ago

z_grouped = torch.cat(test_z, dim=0).view(-1, c.n_transforms_test, c.n_feat) anomaly_score = t2np(torch.mean(z_grouped ** 2, dim=(-2, -1))) train.py line130, 131, when calculate the anomaly_score, much GPU memory needed. And this is can be solved by calculating along with every loop at line 109-112, and then merage the results when the loop is over.

AlessioGalluccio commented 2 years ago

Hi @letmejoin, thank you for the suggestion! I'll try to implement it as soon as possible. Best, Alessio

balablb commented 2 years ago

z_grouped = torch.cat(test_z, dim=0).view(-1, c.n_transforms_test, c.n_feat) anomaly_score = t2np(torch.mean(z_grouped ** 2, dim=(-2, -1))) train.py line130, 131, when calculate the anomaly_score, much GPU memory needed. And this is can be solved by calculating along with every loop at line 109-112, and then merage the results when the loop is over.

Can you share the modified code,please~

AlessioGalluccio commented 2 years ago

It would be very useful if you could share your code, @letmejoin

AlessioGalluccio commented 2 years ago

I updated the code. Let me know if there are problems now @letmejoin @balablb

letmejoin commented 2 years ago

I updated the code. Let me know if there are problems now @balablb

oh, I will test your code as soon. Thks.

balablb commented 2 years ago

I updated the code. Let me know if there are problems now @letmejoin @balablb

it works ~

AlessioGalluccio commented 2 years ago

Thank you very much, I'll close the issue

gaowq2017 commented 2 years ago

Hi, The code change of calculating anormaly_score is error, and the true code can reffer to CSFlow