DSE-MSU / DeepRobust

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

Issues related to graph injection attacks on NIPA #145

Open mmdhhhh opened 11 months ago

mmdhhhh commented 11 months ago

Hello author, I attempted to run the NIPA injection attack in the deeprobust library, but while reviewing the source code, I found some issues in the "deeprobust/graph/rl/nipa_env. py" file (as shown in the following figure). The variable N represents the number of nodes before injecting malicious nodes, self.all_nodes represent all nodes in the original graph. May I ask if self.injected_nodes represents the injected malignant nodes? If so, it should not take the index from the nodes in the original graph, is that correct? `I O6OWS%D}BUSW9GHBC754

ChandlerBang commented 11 months ago

Hi,

The input adjacency matrix already contains the injected nodes. Please see the file below.

https://github.com/DSE-MSU/DeepRobust/blob/fb047ac918ca3525749b8d091898fc5670752e74/examples/graph/test_nipa.py#L60-L62

mmdhhhh commented 11 months ago

Thank you very much for your answer! The input adjacency matrix does indeed include injection nodes, but at this point, the degree of the injected nodes is 0 because the injection nodes have not yet been connected to the nodes in the original graph (the "injecting_nodes" function in the "deeprobust/examples/graph/test_nipa. py" file seems to have only changed the shape of the initial adjacency matrix). However, the variable "N" in the "deeprobust/graph/rl/nipa_env. py" file represents the number of nodes with a degree greater than 0, which is the number of nodes in the original graph (the degree of all nodes in the graph I chose to attack is greater than 0), and the variable "self. all_nodes" should represent the index of all nodes in the original graph. I also debugged the code, which confirms my point. ~PF$YVT){2DA3EP @5~S_YL In the above figure, I printed the shapes of the feature matrices before and after injecting nodes. Before injecting nodes, the number of nodes was 2708, and after injecting nodes, the number of nodes was 2735. Therefore, the index of the injected nodes should be 2708-2734. However, I checked the index stored in the variable "self.injected_nodes" in the "deeprobust/graph/rl/nipa_env. py" file, and it looks like this: R$ XZ}9 @YGOROQQ 4K_X2P The value of the variable "self.injected_nodes" is actually stored between 2681 and 2707. I hope you can check it out and correct me if I'm wrong.

mmdhhhh commented 10 months ago

Hi,

The input adjacency matrix already contains the injected nodes. Please see the file below.

https://github.com/DSE-MSU/DeepRobust/blob/fb047ac918ca3525749b8d091898fc5670752e74/examples/graph/test_nipa.py#L60-L62

Hi,

The input adjacency matrix already contains the injected nodes. Please see the file below.

https://github.com/DSE-MSU/DeepRobust/blob/fb047ac918ca3525749b8d091898fc5670752e74/examples/graph/test_nipa.py#L60-L62

Hello, could you please reply to me?

ChandlerBang commented 10 months ago

Hi mmdhhhh,

Thank you for pointing out. I agree that there is a bug in this file. Can you help me fix this issue and submit a pull request to this repo? I appreciate your help.

mmdhhhh commented 10 months ago

Thank you for your answer! I will submit a pull request soon.