Initialize Graph layer Args: input_channels (int): The size of the input node features output_channels (int): The output size of the node features num_nodes (int): Number of vertices in the graph bias (bool): Whether to apply biases after wei
(self,
input_channels,
output_channels,
num_nodes,
bias=True,
activation = lbann.Relu,
name=None)
| 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 |
| 65 | self.has_bias = bias |
| 66 | |
| 67 | if (self.has_bias): |
| 68 | mat_weights.append(lbann.Weights(initializer = lbann.ConstantInitializer( |
| 69 | value = 0.0), |
| 70 | name = self.name+'_bias_weights')) |
| 71 | self.activation = None |
| 72 | |
| 73 | if activation: |
nothing calls this directly
no test coverage detected