interaction_net¶
- class mfai.pytorch.models.nlam.interaction_net.CheckpointWrapper(module)[source]¶
Bases:
ModuleWrapper for checkpointing a module. Comes from AIFS.
- Parameters:
module (Module)
- forward(*args, **kwargs)[source]¶
Define the computation performed at every call.
Should be overridden by all subclasses. :rtype:
SequentialNote
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.- Parameters:
- Return type:
- class mfai.pytorch.models.nlam.interaction_net.InteractionNet(edge_index, input_dim, update_edges=True, hidden_layers=1, hidden_dim=None, edge_chunk_sizes=None, aggr_chunk_sizes=None, aggr='sum', checkpoint=False)[source]¶
Bases:
MessagePassingImplementation of a generic Interaction Network, from Battaglia et al. (2016).
- Parameters:
- aggregate(messages, index, ptr, dim_size)[source]¶
Overridden aggregation function to: * return both aggregated and original messages, * only aggregate to number of receiver nodes.
- forward(send_rep, rec_rep, edge_rep)[source]¶
Apply interaction network to update the representations of receiver nodes, and optionally the edge representations.
send_rep: (N_send, d_h), vector representations of sender nodes rec_rep: (N_rec, d_h), vector representations of receiver nodes edge_rep: (M, d_h), vector representations of edges used
Returns: rec_rep: (N_rec, d_h), updated vector representations of receiver nodes (optionally) edge_rep: (M, d_h), updated vector representations of edges
- class mfai.pytorch.models.nlam.interaction_net.SplitMLPs(mlps, chunk_sizes)[source]¶
Bases:
ModuleModule that feeds chunks of input through different MLPs. Split up input along dim -2 using given chunk sizes and feeds each chunk through separate MLPs.
- Parameters:
mlps (list[Sequential | CheckpointWrapper])
- mfai.pytorch.models.nlam.interaction_net.make_mlp(blueprint, layer_norm=True, checkpoint=False)[source]¶
Create MLP from list blueprint, with input dimensionality: blueprint[0] output dimensionality: blueprint[-1] and hidden layers of dimensions: blueprint[1], …, blueprint[-2].
if layer_norm is True, includes a LayerNorm layer at the output (as used in GraphCast)
- Return type:
- Parameters: