Image/tensor utilities (spec layer) #
Convenience aliases and helpers for 2‑D images (H×W) and multi‑channel images (C×H×W),
plus padding and window‑extraction utilities used by conv/pooling layers.
A 2-D image tensor of shape [H, W].
Instances For
A C-channel image tensor of shape [C, H, W] (channels-first, like PyTorch NCHW without
N).
Instances For
A 1-D signal tensor of shape [L].
Instances For
A C-channel 1-D signal tensor of shape [C, L] (channels-first).
Instances For
A 3-D volume tensor of shape [D, H, W].
Instances For
A C-channel 3-D volume tensor of shape [C, D, H, W] (channels-first).
Instances For
Cast a MultiChannelImage along definitional equalities of its channel/height/width indices.
This is a dependent-type convenience: it does not change the underlying tensor data, only the type-level shape indices.
Instances For
Explicit-argument version of rw_multi_channel_image.
This is occasionally convenient when elaboration has trouble inferring C2/H2/W2 from context.
Instances For
getValueAtPosition agrees with the generic list-indexing helper get_at_or_zero.
In particular, reading a scalar via the specialized (x, y) accessor is the same as reading
with indices [x, y], where both return 0 out of bounds.
Extract a kH × kW patch from an image starting at (start_i, start_j).
Out-of-bounds pixels are treated as 0, matching the behavior of getValueAtPosition. This is
spec-level "im2col"-style logic (cf. PyTorch nn.Unfold, conceptually).
Instances For
Zero-pad a channels-first image by padding pixels on each spatial axis.
This is the spec analogue of torch.nn.functional.pad (with constant 0 padding). The output
shape is [inC, inH + 2*padding, inW + 2*padding].
Instances For
Characterization lemma for pad_multi_channel under list-indexing (get_at_or_zero).
Reading the padded tensor at [c, p, q] yields 0 in the top/left padding region, and otherwise
reads the original tensor at [c, p - padding, q - padding] (with out-of-bounds falling back to
0 on both sides).
Index-shift lemma for pad_multi_channel.
If (i, j) is in-bounds for the original image, then reading the padded image at
(i + padding, j + padding) returns the same value.
Extract a kH × kW window from each channel of a channels-first image.
The input is typically a padded image, and the result has shape [inC, kH, kW].
Instances For
Increase the channel dimension by zero-padding extra channels.
This is used in some ResNet-style skip connections when inChannels < outChannels. Existing
channels are copied; newly introduced channels are identically zero.
Instances For
Identity on MultiChannelImage (useful as a "no-op" branch in higher-level specs).
Instances For
Construct a C × H × W channels-first image filled with zeros.