mixle.represent.graph module¶
Structured / graph encoding – message passing over a structure’s elements, so edges actually matter.
A molecule, a knowledge graph, a fossil section’s co-occurrence network, a protein contact map: these are
structures, not bags. SetSegmenter gives their elements’ features but throws
the edges away. GraphEmbedding keeps them – a small message-passing net (GCN-style) embeds each element
and then mixes it with its neighbours over layers rounds, so an atom’s vector reflects its bonds and a node’s
reflects its graph context. The output is one (n_elements, dim) block in the same shared space as every
other modality, so a molecule composes with text/images/signals in one HeterogeneousEncoder.
A graph-modality record value is (node_features (n, f), adjacency (n, n)); GraphEncoder is a
ModalityEncoder you drop into the registry via register_encoder. Trains end to end like any encoder.
- class GraphEmbedding(in_features, dim, *, layers=2, name=None)[source]
Bases:
objectA message-passing embedding:
(node_features, adjacency) -> (n_nodes, dim)withlayersGCN rounds.
- class GraphEncoder(embedding)[source]
Bases:
ModalityEncoderA structure modality:
raw = (node_features (n, f), adjacency (n, n))-> per-node vectors in sharedR^dim.- Parameters:
embedding (GraphEmbedding)
- encode(raw)[source]
Torch tensor
(n_units, dim)– gradients flow to the embedding (and, via it, train the encoder).