DSE-MSU / DeepRobust

A pytorch adversarial library for attack and defense methods on images and graphs
MIT License
976 stars 189 forks source link

Attacking Custom Pytorch Geometric Implementation GAT using Mettack #116

Closed akul-goyal closed 2 years ago

akul-goyal commented 2 years ago

Hi,

I am interested in attacking my own GAT model that I coded using Pytorch Geometric. Given the sizes of the graphs, I can use only mettack.py to create a global attack against my model. However, currently, the code seems to be formatted for only GCN based on this function. Is there a way for mettack to be used against a custom model? If so, how would one go about doing so? Would it be as easy as changing this to get the hidden values from the trained model we are trying to attack?

EdisonLeeeee commented 2 years ago

Hi, @akul-goyal

It is not straightforward to use surrogate models other than gcn in metattack. As Pytorch Geometric. uses sparse edge_index for message propagation, you need to implement gat with dense adjacency matrix to calculate the gradients. Specifically, you need a lot of work to achieve this:

akul-goyal commented 2 years ago

If I wanted to attack topology is it possible to modify the existing code to utilize a PyTorch sparse implementation for the adj matrix? I hit a memory wall when converting my adj matrix to dense as coded here. Would the change require changing this? I know the matrix being calculated within the function is dense, but is there any workaround I can use to keep the attack memory efficient? The number of nodes I am dealing with is in the hundreds of thousands.