How to use the pgl.graph_wrapper.StaticGraphWrapper function in pgl

To help you get started, we’ve selected a few pgl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github PaddlePaddle / PGL / examples / static_gcn / train.py View on Github external
val_index = dataset.val_index
    val_label = np.expand_dims(dataset.y[val_index], -1)
    val_index = np.expand_dims(val_index, -1)

    test_index = dataset.test_index
    test_label = np.expand_dims(dataset.y[test_index], -1)
    test_index = np.expand_dims(test_index, -1)

    place = fluid.CUDAPlace(0) if args.use_cuda else fluid.CPUPlace()
    train_program = fluid.Program()
    startup_program = fluid.Program()
    test_program = fluid.Program()
    hidden_size = 16

    with fluid.program_guard(train_program, startup_program):
        gw = pgl.graph_wrapper.StaticGraphWrapper(
            name="graph", graph=dataset.graph, place=place)
        output = pgl.layers.gcn(gw,
                                gw.node_feat["words"],
                                hidden_size,
                                activation="relu",
                                norm=gw.node_feat['norm'],
                                name="gcn_layer_1")
        output = fluid.layers.dropout(
            output, 0.5, dropout_implementation='upscale_in_train')
        output = pgl.layers.gcn(gw,
                                output,
                                dataset.num_classes,
                                activation=None,
                                norm=gw.node_feat['norm'],
                                name="gcn_layer_2")
github PaddlePaddle / PGL / examples / static_gat / train.py View on Github external
val_index = dataset.val_index
    val_label = np.expand_dims(dataset.y[val_index], -1)
    val_index = np.expand_dims(val_index, -1)

    test_index = dataset.test_index
    test_label = np.expand_dims(dataset.y[test_index], -1)
    test_index = np.expand_dims(test_index, -1)

    place = fluid.CUDAPlace(0) if args.use_cuda else fluid.CPUPlace()
    train_program = fluid.Program()
    startup_program = fluid.Program()
    test_program = fluid.Program()
    hidden_size = 16

    with fluid.program_guard(train_program, startup_program):
        gw = pgl.graph_wrapper.StaticGraphWrapper(
            name="graph", graph=dataset.graph, place=place)

        output = pgl.layers.gat(gw,
                                gw.node_feat["words"],
                                hidden_size,
                                activation="elu",
                                name="gat_layer_1",
                                num_heads=8,
                                feat_drop=0.6,
                                attn_drop=0.6,
                                is_test=False)
        output = pgl.layers.gat(gw,
                                output,
                                dataset.num_classes,
                                num_heads=1,
                                activation=None,
github PaddlePaddle / PGL / pgl / graph_wrapper.py View on Github external
def __init__(self, name, graph, place):
        super(StaticGraphWrapper, self).__init__()
        self._initializers = []
        self.__data_name_prefix = name
        self.__create_graph_attr(graph)