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

Method __init__

src/sample.py:10–46  ·  view source on GitHub ↗
(self, dataset, data_path="data", task_type="full")

Source from the content-addressed store, hash-verified

8class Sampler:
9 """Sampling the input graph data."""
10 def __init__(self, dataset, data_path="data", task_type="full"):
11 self.dataset = dataset
12 self.data_path = data_path
13 (self.adj,
14 self.train_adj,
15 self.features,
16 self.train_features,
17 self.labels,
18 self.idx_train,
19 self.idx_val,
20 self.idx_test,
21 self.degree,
22 self.learning_type) = data_loader(dataset, data_path, "NoNorm", False, task_type)
23
24 #convert some data to torch tensor ---- may be not the best practice here.
25 self.features = torch.FloatTensor(self.features).float()
26 self.train_features = torch.FloatTensor(self.train_features).float()
27 # self.train_adj = self.train_adj.tocsr()
28
29 self.labels_torch = torch.LongTensor(self.labels)
30 self.idx_train_torch = torch.LongTensor(self.idx_train)
31 self.idx_val_torch = torch.LongTensor(self.idx_val)
32 self.idx_test_torch = torch.LongTensor(self.idx_test)
33
34 # vertex_sampler cache
35 # where return a tuple
36 self.pos_train_idx = np.where(self.labels[self.idx_train] == 1)[0]
37 self.neg_train_idx = np.where(self.labels[self.idx_train] == 0)[0]
38 # self.pos_train_neighbor_idx = np.where
39
40
41 self.nfeat = self.features.shape[1]
42 self.nclass = int(self.labels.max().item() + 1)
43 self.trainadj_cache = {}
44 self.adj_cache = {}
45 #print(type(self.train_adj))
46 self.degree_p = None
47
48 def _preprocess_adj(self, normalization, adj, cuda):
49 adj_normalizer = fetch_normalization(normalization)

Callers

nothing calls this directly

Calls 1

data_loaderFunction · 0.90

Tested by

no test coverage detected