dgl.softmax_nodes¶
-
dgl.
softmax_nodes
(graph, feat, *, ntype=None)[source]¶ Perform graph-wise softmax on the node features.
For each node v∈V and its feature xv, calculate its normalized feature as follows:
zv=exp(xv)∑u∈Vexp(xu)If the graph is a batch of multiple graphs, each graph computes softmax independently. The result tensor has the same shape as the original node feature.
- Parameters
- Returns
Result tensor.
- Return type
Tensor
Examples
Create two
DGLGraph
objects and initialize their node features.Softmax over one graph:
Softmax over a batched graph:
See also