Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Numerical instability of NNSED #56

Closed
HushTheBlock opened this issue Nov 5, 2020 · 3 comments
Closed

Numerical instability of NNSED #56

HushTheBlock opened this issue Nov 5, 2020 · 3 comments

Comments

@HushTheBlock
Copy link

When I implemented NNSED on my own network, I encountered the following problem:

C:\Users\Administrator\anaconda3\lib\site-packages\karateclub\community_detection\overlapping\nnsed.py:75: RuntimeWarning: invalid value encountered in true_divide
self._W = self._W*(enum/denom)

and this is caused by some zero entries in denom.
After adding the following codes, my issues are resolved successfully, and NNSED can now converge.

def _update_W(self, A):
        enum = A.dot(self._Z.T)
        denom_1 = self._W.dot(self._Z).dot(self._Z.T)
        denom_2 = (A.dot(A.transpose())).dot(self._W)
        denom = denom_1 + denom_2 + **1e-6**
        self._W = self._W*(enum/denom)

def _update_Z(self, A):
        enum = (A.dot(self._W)).transpose()
        denom = np.dot(np.dot(self._W.T, self._W), self._Z) + self._Z + **1e-6**
        self._Z = self._Z*(enum/denom)

I hope this could be fixed in the next version.

@benedekrozemberczki
Copy link
Owner

benedekrozemberczki commented Nov 5, 2020 via email

@benedekrozemberczki
Copy link
Owner

Fixed it.

@HushTheBlock
Copy link
Author

HushTheBlock commented Nov 5, 2020

Sure thing. But I'm new to github so you may need to wait a while.

Ahh sry. I noticed that you fixed the problem. Haha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants