suanrong / SDNE

This is a implementation of SDNE (Structural Deep Network embedding)
http://www.kdd.org/kdd2016/subtopic/view/structural-deep-network-embedding
322 stars 119 forks source link

error in function check_link_reconstruction #1

Closed ciurga closed 7 years ago

ciurga commented 7 years ago

Hi! I ran SDNE with the train data provided and I received this error:

if (data.adj_matrix[x][y] == 1):

IndexError: only integers, slices (:), ellipsis (...), numpy.newaxis (None) and integer or boolean arrays are valid indices

The problem is clearly in the definition of x and y,

x = ind / data.N y = ind % data.N

given that ind is a float, x will be a float and for sure it cannot be used as index for the adjacency matrix. Can you tell where I might be going wrong or why is this caused? Moreover, which is the logic behind this assignment?

Thanks

suanrong commented 7 years ago

I don't know what is going wrong. I don't think the ind could be a float, please check the other part of code, or print the value of ind.

First I get the similarity parewise, and reshape them into an array: similarity = getSimilarity(embedding).reshape(-1)

Then, I calculate the argsort: sortedInd = np.argsort(similarity)

so each of item in sortedInd is a index for a similarity between two vertices in adjacency matrix. since i used reshape, I could calculate the two index: x = ind / data.N y = ind % data.N