From b2c6791e9cf30ae98e71919977f40e866ba6d948 Mon Sep 17 00:00:00 2001 From: Sukrit Gupta Date: Mon, 10 Jun 2019 11:22:19 +0800 Subject: [PATCH] Bug in permutation with new indices. Hi, I work on similar stuff and noticed that there is a bug in your code where you rearrange the matrix according to the indices. I am not sure if the same has been used elsewhere. May please review. Thanks! --- lib/coarsening.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/lib/coarsening.py b/lib/coarsening.py index fc33855..ae13aa4 100644 --- a/lib/coarsening.py +++ b/lib/coarsening.py @@ -228,15 +228,12 @@ def perm_data(x, indices): Mnew = len(indices) assert Mnew >= M xnew = np.empty((N, Mnew)) - for i,j in enumerate(indices): - # Existing vertex, i.e. real data. - if j < M: - xnew[:,i] = x[:,j] - # Fake vertex because of singeltons. - # They will stay 0 so that max pooling chooses the singelton. - # Or -infty ? - else: - xnew[:,i] = np.zeros(N) + for new_node_1, old_node_1 in enumerate(indices): + for new_node_2, old_node_2 in enumerate(indices): + if old_node_1 < N and old_node_2 < M : + xnew[new_node_1, new_node_2] = x[old_node_1, old_node_2] + else: + xnew[new_node_1, new_node_2] = 0 return xnew def perm_adjacency(A, indices):