Skip to content

Latest commit

 

History

History
115 lines (103 loc) · 3.83 KB

broadcast.md

File metadata and controls

115 lines (103 loc) · 3.83 KB

tfgnn.broadcast

View source on GitHub

Broadcasts values from nodes to edges, or from context to nodes or edges.

tfgnn.broadcast(
    graph_tensor: GraphTensor,
    from_tag: IncidentNodeOrContextTag,
    *,
    edge_set_name: Union[Sequence[EdgeSetName], EdgeSetName, None] = None,
    node_set_name: Union[Sequence[NodeSetName], NodeSetName, None] = None,
    feature_value: Optional[Field] = None,
    feature_name: Optional[FieldName] = None
) -> Union[list[Field], Field]

This function broadcasts a feature value from context to nodes or edges if called with from_tag=tfgnn.CONTEXT, or from incident nodes to edges if called with from_tag set to an ordinary node tag like tfgnn.SOURCE or tfgnn.TARGET.

The edge_set_name (or node_set_name, when broadcasting from context) can be set to the name of a single destination, or to a list of names of multiple destinations.

Functionally, there is no difference to calling the underlying functions broadcast_node_to_edges(), broadcast_context_to_nodes(), or broadcast_context_to_edges() directly on individual edge sets or node sets. However, the more generic API of this function provides the proper mirror image of tfgnn.pool(), which comes in handy for some algorithms.

Args

graph_tensor A scalar GraphTensor.
from_tag Values are broadcast from context if this is tfgnn.CONTEXT or from the incident node on each edge with this tag.
edge_set_name The name of the edge set to which values are broadcast, or a non-empty sequence of such names. Unless from_tag=tfgnn.CONTEXT, all named edge sets must have the same incident node set at the given tag.
node_set_name The name of the node set to which values are broadcast, or a non-empty sequence of such names. Can only be passed together with from_tag=tfgnn.CONTEXT. Exactly one of edge_set_name or node_set_name must be set.
feature_value A tensor of shape [num_items, *feature_shape] from which the broadcast values are taken. The first dimension indexes the items from which the broadcast is done (that is, the nodes of the common node set identified by from_tag, or the graph components in the context).
feature_name The name of a feature stored in the graph, for use instead of feature_value. Exactly one of feature_name or feature_value must be set.

Returns

The result of broadcasting to the specified edge set(s) or node set(s). If a single name was specified, the result is is a single tensor. If a list of names was specified, the result is a list of tensors, with parallel indices.