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

load own adjacency matrix and features #21

Open
xypan1232 opened this issue Sep 27, 2018 · 1 comment
Open

load own adjacency matrix and features #21

xypan1232 opened this issue Sep 27, 2018 · 1 comment

Comments

@xypan1232
Copy link

I have my own array for adjacency matrix and features, thus i did not use the load function in utils.py
Could I ask is it right for me to generate adjacency and feature data for training graph cnn. features and adj are full numpy array:

features = sp.csr_matrix(features, dtype=np.float32)
features = normalize(features)
features = np.array(features.todense())
adj = sp.csr_matrix(adj)
adj = normalize(adj + sp.eye(adj.shape[0]))
adj = sparse_mx_to_torch_sparse_tensor(adj)

Another question is that why need "adj + sp.eye(adj.shape[0])" if adj is an adjacency matrix? thanks.

@JTunis
Copy link

JTunis commented Nov 8, 2018

To take a crack at your second question: we want to add the identity matrix to our adjacency matrix in order to add self-loops onto each node. If we did not do this, at each propagation we would only be aggregating the features of each node's neighborhood without accounting for the features of the node itself. Adding self-loops allows us to aggregate a node's features with its neighbor's features (because it acts as its own neighbor).

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