MCPcopy Create free account
hub / github.com/DropEdge/DropEdge / randomedge_sampler

Method randomedge_sampler

src/sample.py:74–92  ·  view source on GitHub ↗

Randomly drop edge and preserve percent% edges.

(self, percent, normalization, cuda)

Source from the content-addressed store, hash-verified

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 """

Callers 1

train_new.pyFile · 0.80

Calls 3

stub_samplerMethod · 0.95
_preprocess_adjMethod · 0.95
_preprocess_feaMethod · 0.95

Tested by

no test coverage detected