peal.architectures.basic_modules

Small nn.Module building blocks used by PEAL’s configurable architectures.

The predictor and generator builders in peal.architectures assemble networks from layer lists; these modules wrap tensor operations (transpose, squeeze, mean, one-hot) so they can appear in nn.Sequential, plus a zennit-friendly residual block and a few attention layers with hand-rolled positional encodings for sequence and image inputs.

Classes

DimensionSwitchAttentionLayer

Cross-attention that maps a spatial feature map to output_size slots.

ImgSelfAttentionLayer

Self-attention over the spatial positions of an image feature map.

Mean

Average over a set of dimensions (global average pooling by default).

OneHotEncoding

One-hot encode integer inputs that arrive as a 2D tensor.

SelfAttentionLayer

Multi-head self-attention over a (B, L, C) sequence.

SkipConnection

Residual block module(x) + downsample(x) with a zennit Sum layer.

Squeeze

Remove singleton dimensions, one torch.squeeze per entry of dims.

Transpose

Module form of x.transpose(dim1, dim2).

Unsqueeze

Insert singleton dimensions, one torch.unsqueeze per entry of dims.