Randomly drop edge and preserve percent% edges.
(self, percent, normalization, cuda)
| 72 | return r_adj, fea |
| 73 | |
| 74 | def randomedge_sampler(self, percent, normalization, cuda): |
| 75 | """ |
| 76 | Randomly drop edge and preserve percent% edges. |
| 77 | """ |
| 78 | "Opt here" |
| 79 | if percent >= 1.0: |
| 80 | return self.stub_sampler(normalization, cuda) |
| 81 | |
| 82 | nnz = self.train_adj.nnz |
| 83 | perm = np.random.permutation(nnz) |
| 84 | preserve_nnz = int(nnz*percent) |
| 85 | perm = perm[:preserve_nnz] |
| 86 | r_adj = sp.coo_matrix((self.train_adj.data[perm], |
| 87 | (self.train_adj.row[perm], |
| 88 | self.train_adj.col[perm])), |
| 89 | shape=self.train_adj.shape) |
| 90 | r_adj = self._preprocess_adj(normalization, r_adj, cuda) |
| 91 | fea = self._preprocess_fea(self.train_features, cuda) |
| 92 | return r_adj, fea |
| 93 | |
| 94 | def vertex_sampler(self, percent, normalization, cuda): |
| 95 | """ |
no test coverage detected