def main(): N = 4 # 頂点の数 D = 4 # dimension edge = [[1, 2], [2, 3], [2, 4], [3, 4]] # Edge x = np.array([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) W = np.array([ [0.5, 0.3, 0, 0], [0.2, 0.1, 0, -0.1], [-0.4, -0.5, 1, 0], [-3, 0, 0, 1], ]) y = 1 g = GNN(N, D, x) alpha = 0.001 A = np.array([0.0, 0.0, 0.0, 0.0]).reshape(4, 1) b = 0 param = {"W": W, "A": A, "b": b} g.GD(alpha, param, y, 1, g.get_adjacency_matrix(edge))
def readout(): N = 4 # 頂点の数 D = 4 # dimension edge = [[1, 2], [2, 3], [2, 4], [3, 4]] # Edge x = np.array([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) W = np.array([ [0.5, 0.3, 0, 0], [0.2, 0.1, 0, -0.1], [-0.4, -0.5, 1, 0], [-3, 0, 0, 1], ]) g = GNN(N, D, x) a = g.aggregate_1(x, g.get_adjacency_matrix(edge)) # print(a) # print(W @ a) nx = g.aggregate_2(W, a) # print(nx) h = g.readout(nx) return h