<jupyter_start><jupyter_text>Load and Visualize Data<jupyter_code>W = np.load('../node2coords/data/soc-karate/karate_adjacency.npy')
labels = np.genfromtxt("../node2coords/data/soc-karate/soc-karate.node_labels")
my_G = graphs.Graph(W, gtype='community')
my_G.info = {}
my_G.info['node_com'] = labels[:,1].astype(int)
my_G.set_coordinates(kind ='community2D', seed=42)
fig, axes = plt.subplots(1, 1, figsize=(5, 4));
my_G.plot_signal(labels[:,1], vertex_size=150, ax=axes);
axes.set_title('Zachary Karate Network', fontsize=20);<jupyter_output><empty_output><jupyter_text>Load and Visualize Representations Learned by node2coords<jupyter_code>path = '../node2coords/power1diff1_tau1_data_karate_eps0.03_sinkh500_dim2_epochs2000_batch34_rho0.05/'<jupyter_output><empty_output><jupyter_text>1. Graph Structural Patterns<jupyter_code>MS = torch.load(path+'encoder/latent_rep/latent_representation_epoch1999.pt', map_location='cpu')
M_S = MS.detach().cpu().numpy()
fig, axes = plt.subplots(1, 2, figsize=(15, 5));
my_G.plot_signal(M_S[:,0], ax=axes[0], vertex_size=80, highlight=np.argmax(M_S[:,0]));
axes[0].set_title('First Graph Structural Pattern', fontsize=18);
my_G.plot_signal(M_S[:,1], ax=axes[1], vertex_size=80, highlight=np.argmax(M_S[:,1]));
axes[1].set_title('Second Graph Structural Pattern', fontsize=18);<jupyter_output><empty_output><jupyter_text>2. Node Coordinates<jupyter_code>lamdas = torch.load(path+'weights/lamdas_it0_epoch1999.pt')
my_lamdas = lamdas.detach().cpu().numpy()
fig, axs = plt.subplots(1, 1)
axs.scatter(my_lamdas[:,0], my_lamdas[:,1], c=labels[:,1], edgecolors='k');
axs.set_xlabel('$\lambda_1$', fontsize=17);
axs.set_ylabel('$\lambda_2$', fontsize=17);
axs.set_title('node2coords',fontsize=20);<jupyter_output><empty_output><jupyter_text>Check Convergence<jupyter_code>objective = np.load(path+'convergence.npy')
fig, axs = plt.subplots(1, 1)
axs.plot(objective);
axs.set_xlabel('epochs', fontsize=17);
axs.set_ylabel('', fontsize=17);
axs.set_title('Convergence',fontsize=20);<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1811062163485071, 'fraction_numerical': 0.04454233969652472, 'mean_word_length': 10.169398907103826, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '362939', 'license': 'MIT', 'n_tokens_mistral': 884, 'n_tokens_neox': 844, 'n_words': 97, 'path': 'see_node2coords_outputs.ipynb', 'repo_name': 'ersisimou/node2coords', 'size': '2043'}