最近在尝试使用 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 是一样的。