Skip to content

Commit 9b15140

Browse files
breakanalysisorazve
andcommitted
Expose graphsage training configuration
Co-authored-by: Olga Razvenskaia <[email protected]>
1 parent 87b0baf commit 9b15140

File tree

1 file changed

+27
-9
lines changed

1 file changed

+27
-9
lines changed

graphdatascience/gnn/gnn_nc_runner.py

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,40 @@
66

77

88
class GNNNodeClassificationRunner(UncallableNamespace, IllegalAttrChecker):
9+
def make_graph_sage_config(self, graph_sage_config):
10+
GRAPH_SAGE_DEFAULT_CONFIG = {"layer_config": {}, "num_neighbors": [25, 10], "dropout": 0.5,
11+
"hidden_channels": 256}
12+
final_sage_config = GRAPH_SAGE_DEFAULT_CONFIG
13+
if graph_sage_config:
14+
bad_keys = []
15+
for key in graph_sage_config:
16+
if key not in GRAPH_SAGE_DEFAULT_CONFIG:
17+
bad_keys.append(key)
18+
if len(bad_keys) > 0:
19+
raise Exception(f"Argument graph_sage_config contains invalid keys {', '.join(bad_keys)}.")
20+
21+
final_sage_config.update(graph_sage_config)
22+
return final_sage_config
23+
924
def train(
10-
self,
11-
graph_name: str,
12-
model_name: str,
13-
feature_properties: List[str],
14-
target_property: str,
15-
relationship_types: List[str],
16-
target_node_label: str = None,
17-
node_labels: List[str] = None,
25+
self,
26+
graph_name: str,
27+
model_name: str,
28+
feature_properties: List[str],
29+
target_property: str,
30+
relationship_types: List[str],
31+
target_node_label: str = None,
32+
node_labels: List[str] = None,
33+
graph_sage_config = None
1834
) -> "Series[Any]": # noqa: F821
35+
1936
mlConfigMap = {
2037
"featureProperties": feature_properties,
2138
"targetProperty": target_property,
2239
"job_type": "train",
2340
"nodeProperties": feature_properties + [target_property],
24-
"relationshipTypes": relationship_types
41+
"relationshipTypes": relationship_types,
42+
"graph_sage_config": self.make_graph_sage_config(graph_sage_config)
2543
}
2644

2745
if target_node_label:

0 commit comments

Comments
 (0)