8.2.3 Advanced Hyperparameter Customization
You can build a GraphWise model using rich hyperparameter customization.
This is done through the following two sub-config classes:
GraphWiseConvLayerConfig
GraphWisePredictionLayerConfig
The following code describes the implementation of the configuration using the above classes in GraphWise model:
Note:
Staring from Graph Server and Client Release 21.2, you can create a model with one of the following options:- only vertex properties
- only edge properties
- both vertex and edge properties
Building a Customized GraphWise Model with Vertex and Edge Properties Using
JShell
opg4j> var weightProperty = analyst.pagerank(trainGraph).getName();
opg4j> var convLayerConfig = analyst.graphWiseConvLayerConfigBuilder().
setNumSampledNeighbors(25).
setActivationFunction(ActivationFunction.TANH).
setWeightInitScheme(WeightInitScheme.XAVIER).
setWeightedAggregationProperty(weightProperty).
build();
opg4j> var predictionLayerConfig = analyst.graphWisePredictionLayerConfigBuilder().
setHiddenDimension(32).
setActivationFunction(ActivationFunction.RELU).
setWeightInitScheme(WeightInitScheme.HE).
build();
opg4j> var model = analyst.supervisedGraphWiseModelBuilder().
setVertexInputPropertyNames("features").
setVertexTargetPropertyName("labels").
setEdgeInputPropertyNames("cost"). //sets the edge properties name
setConvLayerConfigs(convLayerConfig).
setPredictionLayerConfigs(predictionLayerConfig).
build();
Building a Customized GraphWise Model with Vertex and Edge Properties Using Java
String weightProperty = analyst.pagerank(trainGraph).getName()
GraphWiseConvLayerConfig convLayerConfig = analyst.graphWiseConvLayerConfigBuilder()
.setNumSampledNeighbors(25)
.setActivationFunction(ActivationFunction.TANH)
.setWeightInitScheme(WeightInitScheme.XAVIER)
.setWeightedAggregationProperty(weightProperty)
.build();
GraphWisePredictionLayerConfig predictionLayerConfig = analyst.graphWisePredictionLayerConfigBuilder()
.setHiddenDimension(32)
.setActivationFunction(ActivationFunction.RELU)
.setWeightInitScheme(WeightInitScheme.HE)
.build();
SupervisedGraphWiseModel model = analyst.supervisedGraphWiseModelBuilder()
.setVertexInputPropertyNames("features")
.setVertexTargetPropertyName("labels")
.setEdgeInputPropertyNames("cost") //sets the edge properties name
.setConvLayerConfigs(convLayerConfig)
.setPredictionLayerConfigs(predictionLayerConfig)
.build();
Building a Customized GraphWise Model with Vertex Properties Using
Python
weightProperty = analyst.pagerank(train_graph).name
conv_layer_config = dict(num_sampled_neighbors=25,
activation_fn='TANH',
weight_init_scheme='XAVIER',
neighbor_weight_property_name=weightProperty)
conv_layer = analyst.graphwise_conv_layer_config(**conv_layer_config)
pred_layer_config = dict(hidden_dim=32,
activation_fn='RELU',
weight_init_scheme='HE')
pred_layer = analyst.graphwise_pred_layer_config(**pred_layer_config)
params = dict(vertex_target_property_name="labels",
conv_layer_config=[conv_layer],
pred_layer_config=[pred_layer],
vertex_input_property_names=["features"],
seed=17)
model = analyst.supervised_graphwise_builder(**params)
See SupervisedGraphWiseModelBuilder, GraphWiseConvLayerConfigBuilder and GraphWisePredictionLayerConfigBuilder in Javadoc for a full description of all available hyperparameters and their default values.
Parent topic: Using the Supervised GraphWise Algorithm