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

Update mettack.py #150

Merged
merged 1 commit into from
Nov 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Update mettack.py
Solution to OOM in Metattack in a higher version of Pytorch
  • Loading branch information
KaiGuo20 committed Nov 13, 2023
commit 887eda058ae81db913c4cb0c61a15a90050b0ad7
4 changes: 2 additions & 2 deletions deeprobust/graph/global_attack/mettack.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ def log_likelihood_constraint(self, modified_adj, ori_adj, ll_cutoff):
def get_adj_score(self, adj_grad, modified_adj, ori_adj, ll_constraint, ll_cutoff):
adj_meta_grad = adj_grad * (-2 * modified_adj + 1)
# Make sure that the minimum entry is 0.
adj_meta_grad -= adj_meta_grad.min()
adj_meta_grad = adj_meta_grad - adj_meta_grad.min()
# Filter self-loops
adj_meta_grad -= torch.diag(torch.diag(adj_meta_grad, 0))
adj_meta_grad = adj_meta_grad - torch.diag(torch.diag(adj_meta_grad, 0))
# # Set entries to 0 that could lead to singleton nodes.
singleton_mask = self.filter_potential_singletons(modified_adj)
adj_meta_grad = adj_meta_grad * singleton_mask
Expand Down