Randomly drop edge wrt degree (high degree, low probility).
(self, percent, normalization, cuda)
| 122 | return r_adj, r_fea, all_samples |
| 123 | |
| 124 | def degree_sampler(self, percent, normalization, cuda): |
| 125 | """ |
| 126 | Randomly drop edge wrt degree (high degree, low probility). |
| 127 | """ |
| 128 | if percent >= 0: |
| 129 | return self.stub_sampler(normalization, cuda) |
| 130 | if self.degree_p is None: |
| 131 | degree_adj = self.train_adj.multiply(self.degree) |
| 132 | self.degree_p = degree_adj.data / (1.0 * np.sum(degree_adj.data)) |
| 133 | # degree_adj = degree_adj.multi degree_adj.sum() |
| 134 | nnz = self.train_adj.nnz |
| 135 | preserve_nnz = int(nnz * percent) |
| 136 | perm = np.random.choice(nnz, preserve_nnz, replace=False, p=self.degree_p) |
| 137 | r_adj = sp.coo_matrix((self.train_adj.data[perm], |
| 138 | (self.train_adj.row[perm], |
| 139 | self.train_adj.col[perm])), |
| 140 | shape=self.train_adj.shape) |
| 141 | r_adj = self._preprocess_adj(normalization, r_adj, cuda) |
| 142 | fea = self._preprocess_fea(self.train_features, cuda) |
| 143 | return r_adj, fea |
| 144 | |
| 145 | |
| 146 | def get_test_set(self, normalization, cuda): |
nothing calls this directly
no test coverage detected