<jupyter_start><jupyter_text>Create a graph for DGL<jupyter_code>adjmat_path = r"/XXX/adjmat.bin"
with open(adjmat_path, 'rb') as f:
    adj_mat = pickle.load(f)

# Adjacency 
I = np.eye(adj_mat.shape[0])
adj_mat = adj_mat + I
adj_mat
adj_mat = spp.coo_matrix(adj_mat)
g = dgl.DGLGraph(adj_mat)

dgl.save_graphs('KG.dgl', g)<jupyter_output>/data/nkitamura/anaconda3/envs/dgl/lib/python3.6/site-packages/dgl/base.py:45: DGLWarning: Recommend creating graphs by `dgl.graph(data)` instead of `dgl.DGLGraph(data)`.
  return warnings.warn(message, category=category, stacklevel=1)<jupyter_text>Processing a graph with GCN<jupyter_code>class GCN(nn.Module):
    def __init__(self, in_feats, o_feats, num_nodes):
        super(GCN, self).__init__()
        self.num_nodes = num_nodes
        self.conv1 = GraphConv(in_feats, in_feats)
        self.conv2 = GraphConv(in_feats, in_feats)
        self.conv3 = GraphConv(in_feats, o_feats)
        self.final_mapping = nn.Linear(num_nodes, 512)


    def forward(self, g, in_feat):
        h = self.conv1(g, in_feat)
        h = F.relu(h)
        h = self.conv2(g, h)
        h = F.relu(h)
        h = self.conv3(g, h)
        o = F.relu(h)
        o = o.view(1, self.num_nodes)
        o = self.final_mapping(o)
        
        return o
graph_list, _ = dgl.load_graphs('KG.dgl')
g = graph_list[0]
print(g)

joint_rep = torch.rand(45, 1024)
import networkx as nx
g_nx = g.to_networkx()
nx.draw_networkx(g_nx)
model = GCN(1024, 1, g.num_nodes())
out = model(g, joint_rep)
out.shape
model
embeddings_path = r"../data/glove_data/glove_embeddings_300d.bin"
with open(embeddings_path, 'rb') as f:
    emb = pickle.load(f)
len(emb.keys())
emb_tensor = list()
for k,v in emb.items():
    emb_tensor.append(v)
emb_tensor = np.array(emb_tensor)
emb_tensor.shape
a
embeddings_path = r"../data/glove_data/glove_embeddings_300d.bin"


objects_vector == regions_vector
regions_vector<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1345360824742268, 'fraction_numerical': 0.01804123711340206, 'mean_word_length': 3.8163771712158807, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '379005', 'license': 'CC-BY-4.0', 'n_tokens_mistral': 826, 'n_tokens_neox': 790, 'n_words': 141, 'path': 'scripts/GNN.ipynb', 'repo_name': 'gtatiya/sound-spaces', 'size': '1940'}