xnn.gnn.models.megnet.Set2Set#

class xnn.gnn.models.megnet.Set2Set(n_features, steps, layers=1)[source]#

Bases: Module, FastPathModule

Set2Set readout of a set of vectors per structure (Vinyals, Bengio and Kudlur, 2015).

An LSTM reads the query q* of every structure, attention over the rows of the structure (a softmax of x_r . q) forms the readout r, and q* = q + r (concatenation) feeds the next step. The output is the last q*, twice the input width.

Parameters:
  • n_features (int) – Width of the rows.

  • steps (int) – Number of attention steps.

  • layers (int, optional) – Number of LSTM layers, by default 1.

fast_supported(device, dtype)[source]#

The fast stage writes out a plain LSTM (biases, no dropout, no projection).

Parameters:
Return type:

bool

forward(x, index, num_segments)[source]#

Read out x (R, F), whose rows belong to the structures index (R,).

Returns:

The readout (num_segments, 2 F).

Return type:

Tensor

Parameters: