megengine.module.SlidingWindowTranspose¶
- class SlidingWindowTranspose(output_size, kernel_size, padding=0, stride=1, dilation=1, **kwargs)[源代码]¶
Opposite opration of SlidingWindow, sum over the sliding windows on the corresponding input location. Given an input of the size \((N, C, IH, IW, window_h, window_w)\) and
output_size, the output shape would be \((N, C, output\_size_{h}, output\_size_{w})\) and the arguments must satisfy\[\text{IH} = \lfloor \frac{\text{output_size}_{h} + 2 * \text{padding}_{h} - \text{dilation}_{h} * (\text{kernel_size}_{h} - 1) - 1}{\text{stride}_{h}} + 1 \rfloor\]\[\text{IW} = \lfloor \frac{\text{output_size}_{w} + 2 * \text{padding}_{w} - \text{dilation}_{w} * (\text{kernel_size}_{w} - 1) - 1}{\text{stride}_{w}} + 1 \rfloor\]For each output location, we have:
\[\text{out}_{n, c, oh, ow} = \sum_{n,c,oh,ow=location(n, c, ih, iw, wh, ww)}\text{src}_{n, c, ih, iw, wh, ww}\]\[\begin{split}\text{location}(n, c, ih, iw, wh, ww) &= (n, c, oh+wh, ow+ww) \\ \text{where } & oh=-pad_h+ih \times stride_h + (wh-1) \times (dilation_h-1) \\ & ow=-pad_w+iw \times stride_w + (ww-1) \times (dilation_w-1)\end{split}\]- 参数
output_size (
Union[int,Tuple[int,int]]) – the size of the output tensor.kernel_size (
Union[int,Tuple[int,int]]) – the size of the window to take a max over.padding (
Union[int,Tuple[int,int]]) – implicit zero padding to be added on both sides. Default: 0stride (
Union[int,Tuple[int,int]]) – the stride of the window. Default: 1dilation (
Union[int,Tuple[int,int]]) – the dilation of the window. Default: 1
Methods
apply(fn)Applies function
fnto all the modules within this module, including itself.buffers([recursive])Returns an iterable for the buffers of the module.
children(**kwargs)Returns an iterable for all the submodules that are direct attributes of this module.
disable_quantize([value])Sets
module'squantize_disabledattribute and returnmodule.eval()Sets training mode of all the modules within this module (including itself) to
False.forward(inp)load_state_dict(state_dict[, strict])Loads a given dictionary created by
state_dictinto this module.modules(**kwargs)Returns an iterable for all the modules within this module, including itself.
named_buffers([prefix, recursive])Returns an iterable for key buffer pairs of the module, where
keyis the dotted path from this module to the buffer.named_children(**kwargs)Returns an iterable of key-submodule pairs for all the submodules that are direct attributes of this module, where 'key' is the attribute name of submodules.
named_modules([prefix])Returns an iterable of key-module pairs for all the modules within this module, including itself, where 'key' is the dotted path from this module to the submodules.
named_parameters([prefix, recursive])Returns an iterable for key
Parameterpairs of the module, wherekeyis the dotted path from this module to theParameter.named_tensors([prefix, recursive])Returns an iterable for key tensor pairs of the module, where
keyis the dotted path from this module to the tensor.parameters([recursive])Returns an iterable for the
Parameterof the module.register_forward_hook(hook)Registers a hook to handle forward results.
Registers a hook to handle forward inputs.
replace_param(params, start_pos[, seen])Replaces module's parameters with
params, used byParamPacktostate_dict([rst, prefix, keep_var])tensors([recursive])Returns an iterable for the
Tensorof the module.train([mode, recursive])Sets training mode of all the modules within this module (including itself) to
mode.Sets all parameters' grads to zero