henrryzh1 / UR-DMU

Official code for AAAI2023 paper "Dual Memory Units with Uncertainty Regulation for Weakly Supervised Video Anomaly Detection"
MIT License
65 stars 5 forks source link

About the code and equation 5 in the paper #2

Closed YukiFan closed 1 year ago

YukiFan commented 1 year ago

Thanks for sharing the code of this excellent work. But I have some questions about the code and the paper. It will be much appreciated if you could resolve my puzzles.

for code: in model.py, "anchor_nx_new = torch.gather(N_aug_new, 1, A_index.unsqueeze(2).expand([-1, -1, x.size(-1)])).mean(1).reshape(b // 2, n, -1).mean(1) " "A_index" seems wrong, may be "N_index"?

for paper: In equation (5) y_nn, y_an, y_aa are all equal to 1, and yna is equal to 0. Although in paper there exists “The first two terms of Ldm limit the normal memory unit to learn normal patterns, and the last two terms ensure the abnormal pattern learning for abnormal memory unit.” I still can't understand (@@;), could you give me more explanation about why choose 1 or 0 for these four items?

henrryzh1 commented 1 year ago

You can carefully read section 3.3 of our paper.

For code:

anchor_nx_new = torch.gather(N_aug_new, 1, A_index.unsqueeze(2).expand([-1, -1, x.size(-1)])).mean(1).reshape(b // 2, n, -1).mean(1)

Thank you for your careful review of the code, we will correct this error.

For paper:

YukiFan commented 1 year ago

You can carefully read section 3.3 of our paper.

For code:

anchor_nx_new = torch.gather(N_aug_new, 1, A_index.unsqueeze(2).expand([-1, -1, x.size(-1)])).mean(1).reshape(b // 2, n, -1).mean(1)

Thank you for your careful review of the code, we will correct this error.

For paper:

  • In equation(5). The first two terms 𝕪𝕪BCE(Sk;nn,ynn)+BCE(Sk;an,yan) describe an normal video(no abnormal segments) input into the two memory block, so the output Sk;nn of N_mem(normal) should be [1,1,...,1] all ones, Sk;an of A_mem(abnormal) should be [0,0,...,0] all zeros.
  • The last two terms BCE(Sk;n;ka,ynn)+BCE(Sk;a;ka,yan) describe an abnormal video(et least one abnormal segment) input into the two memory blocks, Sk;na of N_mem(normal) should be [1,0,...,0] at least one, Sk;n;ka chooses the topK score. Sk;aa of A_mem(abnormal) also should be [0,0,...,1] at least ones, Sk;a;ka chooses the topK score. You can think it with Fig.3.

Thank you for your thorough response. I'll re-read the paper. (^▽^)