mixle.represent.modality module¶
Deterministic modality vectorization helpers.
vectorize() maps a raw item to a fixed-length vector that can be used by
structure-learning and heterogeneous Bayesian-network workflows:
text/record-> the learned embedding (mixle.represent.fit_embedder());
image(a 2-D or 3-D numeric array) -> grid-pooled intensities (a coarse, deterministic, torch-free descriptor that captures brightness / spatial layout);
signal(a 1-D numeric array) -> per-window statistics (mean, energy, range) across the trace.
The image and signal descriptors are deterministic and dependency-free. They
are intended as a baseline vectorization layer; learned encoders can be placed
behind the same vectorize surface when a workflow needs richer features.
- image_features(img, dim=16, *, grid=None)[source]
A fixed
dimdescriptor of an image: mean intensity over ag x ggrid of cells.imgis(H, W)or(H, W, C); channels are averaged. The grid sidegis chosen sog*gcoversdim(then truncated/padded to exactlydim), giving a coarse spatial-layout vector – enough for an image field to correlate with structured fields in a discovered graph.
- signal_features(sig, dim=16, *, windows=None)[source]
A fixed
dimdescriptor of a 1-D signal: (mean, energy, range) over evenly-spaced windows.
- vectorize(item, kind, *, dim=16, embedder=None)[source]
Map a raw
itemof modalitykindto a fixeddimvector (see module docstring).- Parameters:
item (Any) – the raw item (a string, a record, an image array, a signal array).
kind (str) –
'text'|'record'|'image'|'signal'.dim (int) – output vector dimension.
embedder (Any) – for
text/record, a fittedEmbedderto reuse (else a small one is fit on the single item – pass one for consistency across a corpus).
- Return type: