DSE-MSU / DeepRobust

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

I want to try mettack with my own data set. #83

Closed katsuki-uuu closed 2 years ago

katsuki-uuu commented 2 years ago

I'm sorry to keep repeating this. I want to try an attack with my own dataset in cora dataset format, how do I save the dataset as npz?

I don't know the contents of the cora.npz array, so I don't know how to create the dataset.

Thank you.

ChandlerBang commented 2 years ago

Hi, think you can refer to https://github.com/DSE-MSU/DeepRobust/blob/2a52969fb8b881ac5325a8d0a26a6880aa8b6a9b/deeprobust/graph/global_attack/base_attack.py#L79-L103

katsuki-uuu commented 2 years ago

Thank you. However, it saves the file in npz format, separating it into "mod_adj" and "mod_feature". I would like to save my data in exactly the same format as "cora.npz" and use it as training data for mettack. I don't know how the adj, features and labels are stored as arrays in "cora.npz", so I don't know how to process my data set as in "cora.npz".

I think that if I can save my data as "cora.npz", I can easily train "mettack" with my data.

ChandlerBang commented 2 years ago

Maybe something like np.save and np.savez? Check details here.

You may need some adjustment on the code provided in the above link.

katsuki-uuu commented 2 years ago

Thank you.

That's not what I'm talking about. However, I will study it again.

ChandlerBang commented 2 years ago

I mean, you can try to use np.save to store an array of (adj, features, labels).

katsuki-uuu commented 2 years ago

Thank you. I try it.