Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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")
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,
def __init__(self, name, graph, place):
super(StaticGraphWrapper, self).__init__()
self._initializers = []
self.__data_name_prefix = name
self.__create_graph_attr(graph)