Plugin API¶
Combinatorial¶
Grouped Filter¶
Modules:
-
src–
Classes:
-
FilterParameters–Represents all necessary parameters to implement a (grouped) 1d filter
-
GroupedFilterIndexGenerator–Generates a sequence of indices as needed to apply a grouped filter kernel to a 1d signal.
FilterParameters
¶
FilterParameters(
kernel_size: int,
in_channels: int,
out_channels: int,
groups: int = 1,
stride: int = 1,
input_size: int | None = None,
output_size: int = 1,
)
Represents all necessary parameters to implement a (grouped) 1d filter
without padding.
args:
input_size: Denotes the spatial input size of the filter, consequently we assume kernel_size <= input_size.
However, in some cases input_size might not be known, until this changes we set it to zero.
Typically, we need to run an inference once to set the input_size fields.
kernel_size: Either the size of the kernel in case of e.g. conv1d or pooling layers, or -1 in case of a layer
that expects a flat tensor (e.g., linear layer).
IMPORTANT: The way we represent linear layers is expected to change in the future.
input_channels: The number of input channels in case of a 1d filter. In case of a flat input tensor, e.g., linear layer
GroupedFilterIndexGenerator
¶
GroupedFilterIndexGenerator(params: FilterParameters)
Generates a sequence of indices as needed to apply a grouped filter kernel to a 1d signal.
That means for a one dimensional input tensor with interleaved channels of length spatial_size*in_channels the generator
can produce the correct indices for each group or step depending on the given filter parameters
kernel size, number of input channels and stride.
E.g.,
p = FilterParameters(in_channels=1, out_channels=1, kernel_size=2, stride=1) g = GroupedFilterIndexGenerator(3, p) for g_idx, group in enumerate(g.groups()): print("group id: ", g_idx) for s_idx, step in enumerate(group.steps()): print("step ", s_idx, ': ', list(step))
... "group id: 0" ... "step 0: [0, 1]" ... "step 1: [1, 2]"