BoxModulationND#
- class BoxModulationND(data_dim, max_offset)#
Bases:
ModuleFixed box (hard) window applied to implicit convolutional kernels.
Geometry#
The kernel produced by an implicit kernel network has \(K_d\) taps on axis \(d\), centred at tap index \(\lfloor K_d / 2 \rfloor\) (lag zero). With tap offsets \(o_d = i_d - \lfloor K_d / 2 \rfloor\), the mask is
\[m(o) = \prod_{d=0}^{D-1} \mathbb{1}\bigl[\,|o_d| \le \text{max\_offset}\,\bigr]\]1 = kept, 0 = excluded. Unlike the Gaussian and exponential windows the box is measured in integer taps rather than in normalised grid coordinates, so it is exact at any runtime kernel size and matches a hard crop of the filter at
|offset| > max_offset. It has no parameters.The window is read off
x.shape; thegridargument is accepted for interface compatibility with the other masks and is not used.- param data_dim:
Number of spatial axes of the kernel.
- param max_offset:
Largest tap offset from the kernel centre that is kept, in taps, on every axis. Must be
>= 1; usetorch.nn.Identityfor no window.
- __init__(data_dim, max_offset)#
Initialise the box window; see the class docstring for the arguments.
- forward(grid, x)#
Zero every kernel tap farther than
max_offsetfrom the centre.- Parameters:
- Returns:
xwith the taps outside the window set to zero; same shape and dtype asx.- Return type:
- Raises:
ValueError – If
xdoes not havedata_dimspatial axes.