-
-
Save henry16lin/e09c10a8efe69c917f7fbf655f221ca7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# get adjacency and degree matrix | |
order = sorted(list(G.nodes())) | |
A = nx.to_numpy_matrix(G, nodelist=order) # adjacency matrix | |
I = np.eye(G.number_of_nodes()) | |
A_hat = A + I # 有自循環的相鄰矩陣 | |
D_hat = np.array(np.sum(A_hat, 1)).reshape(-1) | |
D_hat = np.matrix(np.diag(D_hat)) | |
hidden_size = 10 | |
N = G.number_of_nodes() | |
X = np.eye(N) #沒有node feature --> 直接用單位矩陣 | |
W_1 = np.random.normal(loc=0, scale=1, size=(N, hidden_size)) | |
W_2 = np.random.normal(loc=0,scale=1, size=(W_1.shape[1], 2)) # assume it's binary classifier | |
print('adjacency matrix size:',A_hat.shape) | |
print('feature matrix size:',X.shape) | |
print('first layer weight matrix:',W_1.shape) | |
print('second layer weight matrix:',W_2.shape) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment