Skip to content

Commit

Permalink
Update mettack.py
Browse files Browse the repository at this point in the history
Solution to OOM in Metattack in a higher version of Pytorch
  • Loading branch information
KaiGuo20 committed Nov 13, 2023
1 parent 54502e7 commit 887eda0
Showing 1 changed file with 2 additions and 2 deletions.
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

0 comments on commit 887eda0

Please sign in to comment.