tf2_gnn/layers/message_passing/message_passing.py
def _compute_new_node_embeddings(
        self,
        cur_node_embeddings: tf.Tensor,
        messages_per_type: List[tf.Tensor],
        edge_type_to_message_targets: List[tf.Tensor],
        num_nodes: tf.Tensor,
        training: bool,
    ):
        """Aggregate the messages using the aggregation function specified in the params dict.

        If more exotic types of aggregation are required (such as attention methods, etc.), this
        method should be overwritten in the child class.

        NOTE: If you are overriding this method definition, the `messages` input is a list
        containing the return value of the `_message_function` method for each edge type.

        Args:
            cur_node_embeddings: Current node embeddings as a float32 tensor of shape [V, H]
            messages_per_type: A list of messages to be aggregated with length L. Element i of the
            list should be a tensor of the messages for edge type i, with shape [E, H]
            edge_type_to_message_targets: A list of tensors containing the target nodes of each
                message, for each edge type. Each tensor in the list should have shape [E]. For
                example, edge_type_to_message_targets[i][j] = v means that the jth message of edge
                type i is being sent to node v.
            num_nodes: The total number of nodes in the graph, V.

        Returns:
            A tensor of shape [V, H] representing the aggregated messages for each node.

        """
        # Let M be the number of messages (sum of all E):
        message_targets = tf.concat(edge_type_to_message_targets, axis=0)  # Shape [M]
        messages = tf.concat(messages_per_type, axis=0)  # Shape [M, H]

        aggregated_messages = self._aggregation_fn(
            data=messages, segment_ids=message_targets, num_segments=num_nodes
        )
        return self._activation_fn(aggregated_messages)
Aggregate the messages using the aggregation function specified in the params dict.

        If more exotic types of aggregation are required (such as attention methods, etc.), this
        method should be overwritten in the child class.

        NOTE: If you are overriding this method definition, the `messages` input is a list
        containing the return value of the `_message_function` method for each edge type.

        Args:
            cur_node_embeddings: Current node embeddings as a float32 tensor of shape [V, H]
            messages_per_type: A list of messages to be aggregated with length L. Element i of the
            list should be a tensor of the messages for edge type i, with shape [E, H]
            edge_type_to_message_targets: A list of tensors containing the target nodes of each
                message, for each edge type. Each tensor in the list should have shape [E]. For
                example, edge_type_to_message_targets[i][j] = v means that the jth message of edge
                type i is being sent to node v.
            num_nodes: The total number of nodes in the graph, V.

        Returns:
            A tensor of shape [V, H] representing the aggregated messages for each node.

        
Aggregate the messages using the aggregation function specified in the params dict.
If more exotic types of aggregation are required (such as attention methods, etc.), this
method should be overwritten in the child class.

If you are overriding this method definition, the `messages` input is a list
containing the return value of the `_message_function` method for each edge type.

Current node embeddings as a float32 tensor of shape [V, H]
messages_per_type: A list of messages to be aggregated with length L. Element i of the
list should be a tensor of the messages for edge type i, with shape [E, H]
edge_type_to_message_targets: A list of tensors containing the target nodes of each
message, for each edge type. Each tensor in the list should have shape [E]. For
example, edge_type_to_message_targets[i][j] = v means that the jth message of edge
type i is being sent to node v.
num_nodes: The total number of nodes in the graph, V.

A tensor of shape [V, H] representing the aggregated messages for each node.
Aggregate the messages using the aggregation function specified in the params dict . If more exotic types of aggregation are required ( such as attention methods etc . ) this method should be overwritten in the child class . If you are overriding this method definition the ` messages ` input is a list containing the return value of the ` _message_function ` method for each edge type . Current node embeddings as a float32 tensor of shape [ V H ] messages_per_type : A list of messages to be aggregated with length L . Element i of the list should be a tensor of the messages for edge type i with shape [ E H ] edge_type_to_message_targets : A list of tensors containing the target nodes of each message for each edge type . Each tensor in the list should have shape [ E ] . For example edge_type_to_message_targets [ i ] [ j ] = v means that the jth message of edge type i is being sent to node v . num_nodes : The total number of nodes in the graph V . A tensor of shape [ V H ] representing the aggregated messages for each node .
def _compute_new_node_embeddings(
        self,
        cur_node_embeddings: tf.Tensor,
        messages_per_type: List[tf.Tensor],
        edge_type_to_message_targets: List[tf.Tensor],
        num_nodes: tf.Tensor,
        training: bool,
    ):
        message_targets = tf.concat(edge_type_to_message_targets, axis=0)  
        messages = tf.concat(messages_per_type, axis=0)  
        aggregated_messages = self._aggregation_fn(
            data=messages, segment_ids=message_targets, num_segments=num_nodes
        )
        return self._activation_fn(aggregated_messages)
def _compute_new_node_embeddings ( self , cur_node_embeddings : tf . Tensor , messages_per_type : List [ tf . Tensor ] , edge_type_to_message_targets : List [ tf . Tensor ] , num_nodes : tf . Tensor , training : bool , ) : message_targets = tf . concat ( edge_type_to_message_targets , axis = 0 ) messages = tf . concat ( messages_per_type , axis = 0 ) aggregated_messages = self . _aggregation_fn ( data = messages , segment_ids = message_targets , num_segments = num_nodes ) return self . _activation_fn ( aggregated_messages )
Aggregate the messages using the aggregation function specified in the params dict.
Aggregate the messages using the aggregation function specified in the params dict .
"""Aggregate the messages using the aggregation function specified in the params dict.

        If more exotic types of aggregation are required (such as attention methods, etc.), this
        method should be overwritten in the child class.

        NOTE: If you are overriding this method definition, the `messages` input is a list
        containing the return value of the `_message_function` method for each edge type.

        Args:
            cur_node_embeddings: Current node embeddings as a float32 tensor of shape [V, H]
            messages_per_type: A list of messages to be aggregated with length L. Element i of the
            list should be a tensor of the messages for edge type i, with shape [E, H]
            edge_type_to_message_targets: A list of tensors containing the target nodes of each
                message, for each edge type. Each tensor in the list should have shape [E]. For
                example, edge_type_to_message_targets[i][j] = v means that the jth message of edge
                type i is being sent to node v.
            num_nodes: The total number of nodes in the graph, V.

        Returns:
            A tensor of shape [V, H] representing the aggregated messages for each node.

        """ # Let M be the number of messages (sum of all E): # Shape [M] # Shape [M, H]
self
cur_node_embeddings
tf.Tensor
messages_per_type
List[tf.Tensor]
edge_type_to_message_targets
List[tf.Tensor]
num_nodes
tf.Tensor
training
bool