danielzuegner / nettack

Implementation of the paper "Adversarial Attacks on Neural Networks for Graph Data".
https://www.cs.cit.tum.de/daml/forschung/nettack/
MIT License
218 stars 56 forks source link

AttributeError: A1 not found in demo when perturb_structure = False #2

Closed yael432 closed 5 years ago

yael432 commented 5 years ago

Hi,

The following error occurred when setting perturb_structure = False in demo.

AttributeError Traceback (most recent call last)

in () 1 classification_margins_corrupted = [] 2 class_distrs_retrain = [] ----> 3 gcn_retrain = GCN.GCN(sizes, nettack.adj_preprocessed, nettack.X_obs.tocsr(), "gcn_retrain", gpu_id=gpu_id,seed=seed) 4 for _ in range(retrain_iters): 5 print("... {}/{} ".format(_+1, retrain_iters)) nettack-master\nettack\GCN.py in __init__(self, sizes, An, X_obs, name, with_relu, params_dict, gpu_id, seed) 75 self.training = tf.placeholder_with_default(False, shape=()) 76 ---> 77 self.An = tf.SparseTensor(np.array(An.nonzero()).T, An[An.nonzero()].A1, An.shape) 78 self.An = tf.cast(self.An, tf.float32) 79 self.X_sparse = tf.SparseTensor(np.array(X_obs.nonzero()).T, X_obs[X_obs.nonzero()].A1, X_obs.shape) 645 return self.getnnz() 646 else: --> 647 raise AttributeError(attr + " not found") 648 649 def transpose(self, axes=None, copy=False): AttributeError: A1 not found I assume the error is due to the fact that when initializing the Nettack class the 'self.adj_preprocessed' is of type 'scipy.sparse.lil.lil_matrix' and when no structure perturbations are performed the 'self.adj_preprocessed' type remains as is, but when those perturbations are performed by the model the 'self.adj_preprocessed' is of type 'scipy.sparse.csr.csr_matrix' in the end of the poisoning data process.
danielzuegner commented 5 years ago

Thanks for pointing this out. Should be fixed now.