else: node_num = self._node_num adj_mtx_r = np.zeros((node_num, node_num)) for v_i in range(node_num): for v_j in range(node_num): if v_i == v_j: continue adj_mtx_r[v_i, v_j] = self.get_edge_weight(v_i, v_j) return adj_mtx_r if __name__ == '__main__': # load Zachary's Karate graph edge_f = 'data/karate.edgelist' G = graph_util.loadGraphFromEdgeListTxt(edge_f, directed=False) G = G.to_directed() res_pre = 'results/testKarate' graph_util.print_graph_stats(G) t1 = time() embedding = HOPE(4, 0.01) embedding.learn_embedding(graph=G, edge_f=None, is_weighted=True, no_python=True) print('HOPE:\n\tTraining time: %f' % (time() - t1)) viz.plot_embedding2D(embedding.get_embedding()[:, :2], di_graph=G, node_colors=None) plt.show()
n_batch=500, modelfile=[ 'gemben/intermediate/enc_model.json', 'gemben/intermediate/dec_model.json' ], weightfile=[ 'gemben/intermediate/enc_weights.hdf5', 'gemben/intermediate/dec_weights.hdf5' ]) G_X = nx.to_numpy_matrix(G) embedding.learn_embedding(G) G_X_hat = embedding.get_reconstructed_adj() rec_norm = np.linalg.norm(G_X - G_X_hat) print(rec_norm) import pdb pdb.set_trace() # X = embedding.get_embedding() # import pdb # pdb.set_trace() node_colors_arr = [None] * node_colors.shape[0] for idx in range(node_colors.shape[0]): node_colors_arr[idx] = np.where( node_colors[idx, :].toarray() == 1)[1][0] # MAP, prec_curv, err, err_baseline = gr.evaluateStaticGraphReconstruction( # G, embedding, X, None # ) # print('MAP:') # print(MAP) viz.plot_embedding2D(G_X, di_graph=G, node_colors=node_colors_arr) plt.savefig('sdne_sbm_g_x.pdf', bbox_inches='tight')