MCPcopy Create free account
hub / github.com/alibaba/euler / gen_node

Function gen_node

tf_euler/python/dataset/gcn_utils.py:59–81  ·  view source on GitHub ↗
(content_file, node_map, total_label, fea_len, train_num)

Source from the content-addressed store, hash-verified

57 return out_label
58
59def gen_node(content_file, node_map, total_label, fea_len, train_num):
60 label_map = {}
61 label_cnt = 0
62 node_ids = []
63 type = []
64 label = []
65 feature = []
66 with open(os.path.realpath(content_file), 'r') as f:
67 for line in f:
68 features = line.strip().split('\t')
69 if len(features) != fea_len:
70 continue
71 node_ids.append(node_map[features[0]])
72 feature.append(np.asarray(features[1:-1], dtype=int))
73 if (node_map[features[0]]) > train_num:
74 type.append("test")
75 else:
76 type.append("train")
77 if not label_map.has_key(features[-1]):
78 label_map[features[-1]] = label_cnt
79 label_cnt += 1
80 label.append(int2onehot(label_map[features[-1]], total_label))
81 return node_ids, type, label, feature
82
83def parse_graph_file(file_dir, total_label, graph_name, fea_len, train_num):
84 content_file = os.path.join(file_dir, graph_name + ".content")

Callers 1

parse_graph_fileFunction · 0.70

Calls 2

appendMethod · 0.80
int2onehotFunction · 0.70

Tested by

no test coverage detected