terminator.models.layers.term.graph.s2s.TERMEdgeMPNNLayer

class terminator.models.layers.term.graph.s2s.TERMEdgeMPNNLayer(num_hidden, num_in, dropout=0.1, num_heads=None)[source]

Bases: Module

TERM Edge MPNN Layer

A TERM Edge MPNN Layer that updates edges via generating messages and feeding the update through a feedforward network

Variables:
  • W3 (W1, W2,) – Layers for message computation

  • dense (PositionWiseFeedForward) – Transformer position-wise FFN

__init__(num_hidden, num_in, dropout=0.1, num_heads=None)[source]
Parameters:
  • num_hidden (int) – Hidden dimension, and dimensionality of querys in TERMNeighborAttention

  • num_in (int) – Dimensionality of keys and values

  • num_heads (int, default=4) – Number of heads to use in TERMNeighborAttention

  • dropout (float, default=0.1) – Dropout rate

Methods

__init__(num_hidden, num_in[, dropout, ...])

Parameters:
  • num_hidden (int) -- Hidden dimension, and dimensionality of querys in TERMNeighborAttention

forward(h_E, h_EV, E_idx[, mask_E, mask_attend])

Apply one MPNN update on edges in a TERM graph

Attributes

T_destination

alias of TypeVar('T_destination', bound=Mapping[str, Tensor])

dump_patches

This allows better BC support for load_state_dict().

forward(h_E, h_EV, E_idx, mask_E=None, mask_attend=None)[source]

Apply one MPNN update on edges in a TERM graph

Parameters:
  • h_E (torch.Tensor) – Edge features in kNN dense form Shape: n_batch x n_terms x n_nodes x k x n_hidden

  • h_EV (torch.Tensor) – ‘Neighbor’ edge features, or all edges which share a ‘central residue’ with that edge, as well as the node features for both nodes that compose that edge. Shape: n_batch x n_terms x n_nodes x k x n_in

  • mask_E (torch.ByteTensor or None) – Mask for message-passing regarding TERM edges Shape : n_batch x n_terms x n_nodes

  • mask_attend (torch.ByteTensor or None) – Mask for message-passing regarding ‘neighbor’ edges Shape: n_batch x n_terms x n_nodes x k

Returns:

h_E – Updated edge embeddings Shape: n_batch x n_terms x n_nodes x k x n_hidden

Return type:

torch.Tensor