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

Function load_reddit_data

src/utils.py:127–157  ·  view source on GitHub ↗
(normalization="AugNormAdj", porting_to_torch=True, data_path=datadir)

Source from the content-addressed store, hash-verified

125
126
127def load_reddit_data(normalization="AugNormAdj", porting_to_torch=True, data_path=datadir):
128 adj, features, y_train, y_val, y_test, train_index, val_index, test_index = loadRedditFromNPZ(data_path)
129 labels = np.zeros(adj.shape[0])
130 labels[train_index] = y_train
131 labels[val_index] = y_val
132 labels[test_index] = y_test
133 adj = adj + adj.T + sp.eye(adj.shape[0])
134 train_adj = adj[train_index, :][:, train_index]
135 degree = np.sum(train_adj, axis=1)
136
137 features = torch.FloatTensor(np.array(features))
138 features = (features-features.mean(dim=0))/features.std(dim=0)
139 train_features = torch.index_select(features, 0, torch.LongTensor(train_index))
140 if not porting_to_torch:
141 features = features.numpy()
142 train_features = train_features.numpy()
143
144 adj_normalizer = fetch_normalization(normalization)
145 adj = adj_normalizer(adj)
146 train_adj = adj_normalizer(train_adj)
147
148 if porting_to_torch:
149 train_adj = sparse_mx_to_torch_sparse_tensor(train_adj).float()
150 labels = torch.LongTensor(labels)
151 adj = sparse_mx_to_torch_sparse_tensor(adj).float()
152 degree = torch.LongTensor(degree)
153 train_index = torch.LongTensor(train_index)
154 val_index = torch.LongTensor(val_index)
155 test_index = torch.LongTensor(test_index)
156 learning_type = "inductive"
157 return adj, train_adj, features, train_features, labels, train_index, val_index, test_index, degree, learning_type
158
159
160

Callers 1

data_loaderFunction · 0.85

Calls 3

fetch_normalizationFunction · 0.90
loadRedditFromNPZFunction · 0.85

Tested by

no test coverage detected