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

Method forward

python/lbann/modules/graph/sparse/GatedGraphConv.py:64–93  ·  view source on GitHub ↗

Call the GatedGraphConv Args: node_feature_mat (Layer): Node feature matrix with the shape of (num_nodes,input_channels) source_indices (Layer): Source node indices of the edges with shape (num_nodes) target_indices (Layer): Target node indices of the edge

(self, node_feature_mat, source_indices, target_indices)

Source from the content-addressed store, hash-verified

62
63
64 def forward(self, node_feature_mat, source_indices, target_indices):
65 """Call the GatedGraphConv
66 Args:
67 node_feature_mat (Layer): Node feature matrix with the shape of (num_nodes,input_channels)
68 source_indices (Layer): Source node indices of the edges with shape (num_nodes)
69 target_indices (Layer): Target node indices of the edges with shape (num_nodes)
70 Returns:
71 (Layer) : The output after kernel ops. The output can passed into another Graph Conv layer
72 directly
73 """
74
75 if (self.input_channel_size < self.output_channel_size):
76 num_zeros = self.output_channel_size - self.input_channel_size
77 print(num_zeros)
78 zeros = lbann.Constant(value = 0, num_neurons = [self.num_nodes,num_zeros], name = self.name+'_padded')
79 node_feature_mat = lbann.Concatenation(node_feature_mat, zeros, axis = 1)
80
81 elif (input_features > self.output_channel_size):
82 ValueError('The feature size of the nodes {} cannot be greater than the output dimension {}'.
83 format(input_features, self.output_channel_size))
84
85 for layer in range(self.num_layers):
86
87 messages = self.nns[layer](node_feature_mat)
88 neighborhoods = GraphExpand(messages, target_indices)
89 aggregate = GraphReduce(neighborhoods,source_indices, [self.num_nodes, self.output_channel_size])
90
91 node_feature_mat = self.rnn(aggregate, node_feature_mat)
92
93 return node_feature_mat

Callers

nothing calls this directly

Calls 3

GraphExpandFunction · 0.90
GraphReduceFunction · 0.90
printFunction · 0.50

Tested by

no test coverage detected