【GraphSAGE 源碼學習】輸入的數據結構

最近在嘗試使用 GraphSAGE 做 embedding,做個筆記。

G 圖結構

文件:toy-ppi-G.json

數據通過 json 加載之後,得到一個 dict,其中包含的關鍵字:[‘nodes’, ‘directed’, ‘multigraph’, ‘graph’, ‘links’]。

nodes

G_data[‘nodes’] 包含所有的節點, 每個節點(node)包含屬性 [‘test’, ‘label’, ‘id’, ‘val’, ‘feature’]。

node

test 和 val 是 bool 值。同一個結點,test 和 val 不同時爲 True
id 就是結點的 id 嘍。
feature 是個 list,大小是 50,其中的元素是 float。
label 也是個 list,大小是 121, 類型是 int。注意 label 不是 one-hot。(爲什麼是 121 維呢?)

directed

bool

multigraph

bool

graph

dict
但是隻有一個值 {name: “disjoint_union( , )”}

links

是一個 list ,每個元素是一個字典,包括 [‘source’, ‘target’, ‘test_removed’, ‘train_removed’]

所有 test_removed == True 的邊的兩端結點,都是 test == True
所有 train_removed == True 的邊包括 test_removed == True 的邊,以及兩端 val == True 的邊。

id map

dict
id 到 id 的映射

class map

id 到 label 的映射。這個和 G[‘nodes’] 裏面的 id 和 label 是一樣的。

GraphSAGE 輸入結構

在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章