MCPcopy Create free account
hub / github.com/LBANN/lbann / GraphConv

Class GraphConv

python/lbann/modules/graph/sparse/GraphConv.py:7–115  ·  view source on GitHub ↗

Graph Conv layer. See: https://arxiv.org/abs/1609.02907

Source from the content-addressed store, hash-verified

5import math
6
7class GraphConv(Module):
8 """ Graph Conv layer. See:
9
10 https://arxiv.org/abs/1609.02907
11
12 """
13
14 global_count = 0
15
16 def __init__(self,
17 input_channels,
18 output_channels,
19 num_nodes,
20 bias=True,
21 activation = lbann.Relu,
22 name=None):
23 """Initialize Graph layer
24
25 Args:
26 input_channels (int): The size of the input node features
27 output_channels (int): The output size of the node features
28 num_nodes (int): Number of vertices in the graph
29 bias (bool): Whether to apply biases after weights transform
30 activation (type): Activation layer for the node features. If None, then no activation is
31 applied. (default: lbann.Relu)
32 name (str): Default name of the layer is Graph_{number}
33 """
34 super().__init__()
35
36 ## Add variables
37
38 self.input_channel_size = input_channels
39 self.output_channel_size = output_channels
40 self.num_nodes = num_nodes
41
42 ## Add Name for the components for the layer
43 GraphConv.global_count +=1
44 self.name = (name
45 if name
46 else 'Graph_{}'.format(GraphConv.global_count))
47
48 ## Initialize weights for the matrix
49 value = math.sqrt(6/ (input_channels + output_channels))
50
51 mat_weights = []
52 id_weights = []
53
54 mat_weights.append(lbann.Weights(initializer = lbann.UniformInitializer(
55 min = -value,
56 max = value),
57 name = self.name+'_Weights'))
58
59 id_weights.append(lbann.Weights(initializer = lbann.UniformInitializer(
60 min = -value,
61 max = value),
62 name = self.name+'_ID_Weights'))
63
64 ## Initialize bias variables

Callers 1

GraphConvLayerFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected