deephyper.keras.layers.AttentionCOS#

class deephyper.keras.layers.AttentionCOS(*args: Any, **kwargs: Any)[source]#

Bases: Layer

COS Attention.

Check details here https://arxiv.org/abs/1803.07294

The attention coefficient between node $i$ and $j$ is calculated as:

\[\textbf{a}(\textbf{Wh}_i || \textbf{Wh}_j)\]

where \(\textbf{a}\) is a trainable vector.

Parameters:
  • state_dim (int) – number of output channels.

  • attn_heads (int) – number of attention heads.

Methods

build

call

Apply the layer on input tensors.

__call__(*args: Any, **kwargs: Any) Any#

Call self as a function.

call(inputs, **kwargs)[source]#

Apply the layer on input tensors.

Parameters:

inputs (list) – X (tensor): node feature tensor N (int): number of nodes targets (tensor): target node index tensor sources (tensor): source node index tensor degree (tensor): node degree sqrt tensor (for GCN attention)

Returns:

attention coefficient tensor (batch, E, H, 1)

Return type:

attn_coef (tensor)