|
|
@@ -41,25 +41,25 @@ def dropout_sparse_tf(x, keep_prob, num_nonzero_elems): |
|
|
|
return pre_out * (1./keep_prob)
|
|
|
|
|
|
|
|
|
|
|
|
def graph_conv_torch():
|
|
|
|
def dense_graph_conv_torch():
|
|
|
|
torch.random.manual_seed(0)
|
|
|
|
latent, adjacency_matrices = prepare_data()
|
|
|
|
latent = torch.tensor(latent)
|
|
|
|
adj_mat = adjacency_matrices[0]
|
|
|
|
adj_mat = torch.tensor(adj_mat)
|
|
|
|
conv = decagon_pytorch.convolve.GraphConv(10, 10,
|
|
|
|
conv = decagon_pytorch.convolve.DenseGraphConv(10, 10,
|
|
|
|
adj_mat)
|
|
|
|
latent = conv(latent)
|
|
|
|
return latent
|
|
|
|
|
|
|
|
|
|
|
|
def dropout_graph_conv_activation_torch(keep_prob=1.):
|
|
|
|
def dense_dropout_graph_conv_activation_torch(keep_prob=1.):
|
|
|
|
torch.random.manual_seed(0)
|
|
|
|
latent, adjacency_matrices = prepare_data()
|
|
|
|
latent = torch.tensor(latent)
|
|
|
|
adj_mat = adjacency_matrices[0]
|
|
|
|
adj_mat = torch.tensor(adj_mat)
|
|
|
|
conv = decagon_pytorch.convolve.DropoutGraphConvActivation(10, 10,
|
|
|
|
conv = decagon_pytorch.convolve.DenseDropoutGraphConvActivation(10, 10,
|
|
|
|
adj_mat, keep_prob=keep_prob)
|
|
|
|
latent = conv(latent)
|
|
|
|
return latent
|
|
|
@@ -173,7 +173,7 @@ def test_sparse_multi_dgca(): |
|
|
|
|
|
|
|
|
|
|
|
def test_graph_conv():
|
|
|
|
latent_dense = graph_conv_torch()
|
|
|
|
latent_dense = dense_graph_conv_torch()
|
|
|
|
latent_sparse = sparse_graph_conv_torch()
|
|
|
|
|
|
|
|
assert np.all(latent_dense.detach().numpy() == latent_sparse.detach().numpy())
|
|
|
@@ -206,7 +206,7 @@ def test_dropout_graph_conv_activation(): |
|
|
|
keep_prob += np.finfo(np.float32).eps
|
|
|
|
print('keep_prob:', keep_prob)
|
|
|
|
|
|
|
|
latent_dense = dropout_graph_conv_activation_torch(keep_prob)
|
|
|
|
latent_dense = dense_dropout_graph_conv_activation_torch(keep_prob)
|
|
|
|
latent_dense = latent_dense.detach().numpy()
|
|
|
|
print('latent_dense:', latent_dense)
|
|
|
|
|
|
|
@@ -239,7 +239,7 @@ def test_multi_dgca(): |
|
|
|
multi_sparse = decagon_pytorch.convolve.SparseMultiDGCA([10,] * len(adjacency_matrices), 10, adjacency_matrices_sparse, keep_prob=keep_prob)
|
|
|
|
|
|
|
|
torch.random.manual_seed(0)
|
|
|
|
multi = decagon_pytorch.convolve.MultiDGCA([10,] * len(adjacency_matrices), 10, adjacency_matrices, keep_prob=keep_prob)
|
|
|
|
multi = decagon_pytorch.convolve.DenseMultiDGCA([10,] * len(adjacency_matrices), 10, adjacency_matrices, keep_prob=keep_prob)
|
|
|
|
|
|
|
|
print('len(adjacency_matrices):', len(adjacency_matrices))
|
|
|
|
print('len(multi_sparse.sparse_dgca):', len(multi_sparse.sparse_dgca))
|
|
|
|