abduallahmohamed / Social-STGCNN

Code for "Social-STGCNN: A Social Spatio-Temporal Graph Convolutional Neural Network for Human Trajectory Prediction" CVPR 2020
MIT License
483 stars 141 forks source link

Why should we choose the normalized laplacian matrix? #55

Closed DarrenRuan closed 2 years ago

DarrenRuan commented 2 years ago

Hi,

Could I ask a following question about why should we choose the normalized Laplacian matrix? (just like what have been mentioned in #22)

For the normalized Laplacian matrix nx.normalized_laplacian_matrix, the sum of the first row is equal to the sum of the first column (not guaranteed to be 0)? The example below is the same as the given example in #22 . Is there any benefit to using the normalized Laplacian matrix instead of the normalized adjacency matrix?

>>> import numpy as np
>>> import networkx as nx
>>> A = np.asarray([[0,5,9],[5,0,8],[9,8,0]])
>>> A_hat = A+np.eye(3)
>>> G = nx.from_numpy_matrix(A_hat)
>>> A_lapl = nx.normalized_laplacian_matrix(G).toarray()
>>> A_lapl
array([[ 0.93333333, -0.34503278, -0.54772256],
       [-0.34503278,  0.92857143, -0.50395263],
       [-0.54772256, -0.50395263,  0.94444444]])
>>> np.sum(A_lapl,axis=0)
array([ 0.040578  ,  0.07958602, -0.10723074])
>>> np.sum(A_lapl,axis=1)
array([ 0.040578  ,  0.07958602, -0.10723074])

In the original ST-GCN, it shows they used normalized adjacency matrix: https://github.com/yysijie/st-gcn/blob/221c0e152054b8da593774c0d483e59befdb9061/net/utils/graph.py#L139 The function normalize_digraph is about column normalization. And the function normalize_undigraph is about the symmetric normalized matrix.

Really appreciate your help in advance!

abduallahmohamed commented 2 years ago

As far as I remember, the normalized laplacian had better performance than the other form. Also, as I recall the other form is an approximation for the laplacian.

Abduallah Mohamed abduallahmohamed.com

On Wed, Oct 20, 2021 at 2:11 PM DarrenRuan @.***> wrote:

Hi,

Could I ask a following question about why should we choose the normalized Laplacian matrix? (just like what have been mentioned in #22 https://github.com/abduallahmohamed/Social-STGCNN/issues/22)

For the normalized Laplacian matrix, the sum of the first row is equal to the sum of the first column (not guaranteed to be 0)? The example below is the same as the given example in #22 https://github.com/abduallahmohamed/Social-STGCNN/issues/22 . Is there any benefit to using the normalized Laplacian matrix instead of the normalized adjacency matrix?

import numpy as np>>> import networkx as nx>>> A = np.asarray([[0,5,9],[5,0,8],[9,8,0]])>>> A_hat = A+np.eye(3)>>> G = nx.from_numpy_matrix(A_hat)>>> A_lapl = nx.normalized_laplacian_matrix(G).toarray()>>> A_laplarray([[ 0.93333333, -0.34503278, -0.54772256], [-0.34503278, 0.92857143, -0.50395263], [-0.54772256, -0.50395263, 0.94444444]])>>> np.sum(A_lapl,axis=0)array([ 0.040578 , 0.07958602, -0.10723074])>>> np.sum(A_lapl,axis=1)array([ 0.040578 , 0.07958602, -0.10723074])

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/abduallahmohamed/Social-STGCNN/issues/55, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFIVLG2YRWBX2KIU4JS5Z6DUH4H5ZANCNFSM5GML6QIQ .