pygip.models.attack.CEGA

Module Attributes

class pygip.models.attack.CEGA.CEGA(dataset, attack_node_fraction, model_path=None)[source]

Bases: BaseAttack

_abc_impl = <_abc_data object>
attack(seed=1, cuda=None, LR=0.001, TGT_LR=0.01, EVAL_EPOCH=10, TGT_EPOCH=10, WARMUP_EPOCH=4, dropout=False, model_performance=True, **kwargs)[source]

Execute the attack.

supported_api_types = {'dgl'}
class pygip.models.attack.CEGA.GCN_drop(*args: Any, **kwargs: Any)[source]

Bases: Module

forward(g, features)[source]
class pygip.models.attack.CEGA.GcnNet(*args: Any, **kwargs: Any)[source]

Bases: Module

forward(g, features, return_hidden=False)[source]
pygip.models.attack.CEGA.accuracy(output, labels)[source]
pygip.models.attack.CEGA.attack0(dataset_name, seed, cuda, attack_node_arg=0.25, file_path='', LR=0.001, TGT_LR=0.01, EVAL_EPOCH=1000, TGT_EPOCH=1000, WARMUP_EPOCH=400, dropout=False, model_performance=True, **kwargs)[source]
pygip.models.attack.CEGA.aug_normalized_adjacency(adj)[source]
pygip.models.attack.CEGA.aug_random_walk(adj)[source]
pygip.models.attack.CEGA.calculate_entropy(probs)[source]
pygip.models.attack.CEGA.compute_distance(_i, _j, features_aax)[source]
pygip.models.attack.CEGA.compute_rank(tensor, element)[source]
pygip.models.attack.CEGA.convert_pyg_to_dgl(pyg_data)[source]

Converts a PyTorch Geometric Data object into a DGLGraph.

Parameters:

pyg_data (torch_geometric.data.Data) – PyTorch Geometric Data object.

Returns:

The converted DGL graph.

Return type:

dgl.DGLGraph

pygip.models.attack.CEGA.evaluate(model, g, features, labels, mask)[source]
pygip.models.attack.CEGA.find_short_dist(embedding_pool, cluster_centers)[source]
pygip.models.attack.CEGA.get_current_neighbors_1(cur_nodes, adj_matrix)[source]
pygip.models.attack.CEGA.get_current_neighbors_dense(cur_nodes, adj_matrix2)[source]
pygip.models.attack.CEGA.get_entropy_contribute(npy_m1, npy_m2)[source]
pygip.models.attack.CEGA.get_max_info_entropy_node_set(idx_used, high_score_nodes, labels, batch_size, adj_matrix2, num_class, model_prediction)[source]
pygip.models.attack.CEGA.get_max_nnd_node_dense(idx_used, high_score_nodes, min_distance, distance_aax, num_ones, num_node, adj_matrix2, gamma=1)[source]
pygip.models.attack.CEGA.get_receptive_fields_dense(cur_neighbors, selected_node, weighted_score, adj_matrix2)[source]
pygip.models.attack.CEGA.init_mask(C, sub_train_mask, sub_labels)[source]
pygip.models.attack.CEGA.load_data(dataset_name)[source]
pygip.models.attack.CEGA.load_data_from_grain(path='./data', dataset='cora')[source]

ind.[:dataset].x => the feature vectors of the training instances (scipy.sparse.csr.csr_matrix) ind.[:dataset].y => the one-hot labels of the labeled training instances (numpy.ndarray) ind.[:dataset].allx => the feature vectors of both labeled and unlabeled training instances (csr_matrix) ind.[:dataset].ally => the labels for instances in ind.dataset_str.allx (numpy.ndarray) ind.[:dataset].graph => the dict in the format {index: [index of neighbor nodes]} (collections.defaultdict) ind.[:dataset].tx => the feature vectors of the test instances (scipy.sparse.csr.csr_matrix) ind.[:dataset].ty => the one-hot labels of the test instances (numpy.ndarray) ind.[:dataset].test.index => indices of test instances in graph, for the inductive setting

pygip.models.attack.CEGA.normalize(mx)[source]

Row-normalize sparse matrix

pygip.models.attack.CEGA.page_rank(graph, damping_factor=0.85, max_iter=100, tol=1e-08)[source]
pygip.models.attack.CEGA.parse_index_file(filename)[source]
pygip.models.attack.CEGA.perturb_avg(net, sub_g, sub_features, num_perturbations, noise_level)[source]
pygip.models.attack.CEGA.perturb_features(sub_features, noise_level=0.05)[source]
pygip.models.attack.CEGA.quantile_selection(A, B, C, index_1, index_2, index_3, sub_train_mask, sub_train_mask_new, num_each)[source]
pygip.models.attack.CEGA.rank_centrality(sub_g, sub_train_mask, sub_train_mask_new, num_each, return_rank=True)[source]
pygip.models.attack.CEGA.rank_cluster(net, sub_g, sub_features, labels, total_sub_nodes, sub_train_mask, sub_train_mask_new, num_clusters, num_each, return_rank=True)[source]
pygip.models.attack.CEGA.rank_density(net, sub_g, sub_features, sub_train_mask, sub_train_mask_new, num_each, num_clusters, return_rank=True)[source]
pygip.models.attack.CEGA.rank_diversity(net, sub_g, sub_features, sub_train_mask, sub_train_mask_new, num_each, num_clusters, rho, return_rank=True)[source]
pygip.models.attack.CEGA.rank_entropy(net, sub_g, sub_features, sub_train_mask, sub_train_mask_new, num_each, return_rank=True)[source]
pygip.models.attack.CEGA.rank_perturb(net, sub_g, sub_features, num_perturbations, sub_train_mask, sub_train_mask_new, noise_level, num_each, return_rank=True)[source]
pygip.models.attack.CEGA.set_seed(seed)[source]
pygip.models.attack.CEGA.sparse_mx_to_torch_sparse_tensor(sparse_mx)[source]

Convert a scipy sparse matrix to a torch sparse tensor.

pygip.models.attack.CEGA.update_sub_train_mask(num_each, sub_train_mask, sub_train_mask_new)[source]