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

utils.MLPCenter issue #2

Closed
zjz82108008 opened this issue Jun 23, 2022 · 1 comment
Closed

utils.MLPCenter issue #2

zjz82108008 opened this issue Jun 23, 2022 · 1 comment

Comments

@zjz82108008
Copy link

zjz82108008 commented Jun 23, 2022

utils.MLPCenter block seems to be something wrong.
The output of the model was not used in the test section:

                scores = torch.matmul(acts, patterns) # 512, num_blocks, vary from 0 to 1
                mask, labels = torch.topk(scores, k=int(num_blocks*0.2), dim=-1)
                mask = mask > 0
                pred = model(input)
                pred = torch.topk(pred, k=int(num_blocks*0.2), dim=-1)[1]

                for x, m, s in zip(labels, mask, scores):
                    if m.sum().item() == 0:
                        continue
                    x = sum([s[xx] for xx in x.cpu()]).item()
                    y = s.sum().item()
                    acc.append( x / y)
                cur_acc = np.mean(acc)
@zzy14
Copy link
Member

zzy14 commented Jun 26, 2022

Hi, thanks for pointing out this issue. labels, mask, scores should be pred, mask, scores instead. It has been solved.

@zzy14 zzy14 closed this as completed Jun 26, 2022
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

No branches or pull requests

2 participants