torchlib.module.layers package

Submodules

torchlib.module.layers.balanceconv2d module

class torchlib.module.layers.balanceconv2d.BalaConv2d(in_channels, out_channels, kernel_size, stride=1, padding=0, dilation=1, groups=1, bias=False, padding_mode='zeros')

Bases: torch.nn.modules.conv._ConvNd

Applies a 2D Balanced convolution over an input signal composed of several input planes.

In the simplest case, the output value of the layer with input size \((N, C_{\text{in}}, H, W)\) and output \((N, C_{\text{out}}, H_{\text{out}}, W_{\text{out}})\) can be precisely described as:

(1)\[{\bm Z}_{n_o, c_i, h_o, w_o} = \sum_{h=0}^{H_k-1}\sum_{w=0}^{W_k-1} \left[{\bm I}_{n_o, c_i, h_o + h - 1, w_o + w - 1} + {\bm K}_{c_o, h, w} - {\bm I}_{n_o, c_i, h_o + h - 1, w_o + w - 1} \cdot {\bm K}_{c_o, h, w}\right]. \]

where \(\star\) is the valid 2D cross-correlation operator, \(N\) is a batch size, \(C\) denotes a number of channels, \(H\) is a height of input planes in pixels, and \(W\) is width in pixels.

  • stride controls the stride for the cross-correlation, a single number or a tuple.

  • padding controls the amount of implicit zero-paddings on both sides for padding number of points for each dimension.

  • dilation controls the spacing between the kernel points; also known as the à trous algorithm. It is harder to describe, but this `link`_ has a nice visualization of what dilation does.

  • groups controls the connections between inputs and outputs. in_channels and out_channels must both be divisible by groups. For example,

    • At groups=1, all inputs are convolved to all outputs.

    • At groups=2, the operation becomes equivalent to having two conv layers side by side, each seeing half the input channels, and producing half the output channels, and both subsequently concatenated.

    • At groups= in_channels, each input channel is convolved with its own set of filters, of size: \(\left\lfloor\frac{out\_channels}{in\_channels}\right\rfloor\).

The parameters kernel_size, stride, padding, dilation can either be:

  • a single int – in which case the same value is used for the height and width dimension

  • a tuple of two ints – in which case, the first int is used for the height dimension, and the second int for the width dimension

Note

Depending of the size of your kernel, several (of the last) columns of the input might be lost, because it is a valid cross-correlation, and not a full cross-correlation. It is up to the user to add proper padding.

Note

When groups == in_channels and out_channels == K * in_channels, where K is a positive integer, this operation is also termed in literature as depthwise convolution.

In other words, for an input of size \((N, C_{in}, H_{in}, W_{in})\), a depthwise convolution with a depthwise multiplier K, can be constructed by arguments \((in\_channels=C_{in}, out\_channels=C_{in} \times K, ..., groups=C_{in})\).

Parameters
  • in_channels (int) – Number of channels in the input image

  • out_channels (int) – Number of channels produced by the convolution

  • kernel_size (int or tuple) – Size of the convolving kernel

  • stride (int or tuple, optional) – Stride of the convolution. Default: 1

  • padding (int or tuple, optional) – Zero-padding added to both sides of the input. Default: 0

  • padding_mode (string, optional) – zeros

  • dilation (int or tuple, optional) – Spacing between kernel elements. Default: 1

  • groups (int, optional) – Number of blocked connections from input channels to output channels. Default: 1

  • bias (bool, optional) – If True, adds a learnable bias to the output. Default: True

Shape:
  • Input: \((N, C_{in}, H_{in}, W_{in})\)

  • Output: \((N, C_{out}, H_{out}, W_{out})\) where

    \[H_{out} = \left\lfloor\frac{H_{in} + 2 \times \text{padding}[0] - \text{dilation}[0] \times (\text{kernel\_size}[0] - 1) - 1}{\text{stride}[0]} + 1\right\rfloor \]
    \[W_{out} = \left\lfloor\frac{W_{in} + 2 \times \text{padding}[1] - \text{dilation}[1] \times (\text{kernel\_size}[1] - 1) - 1}{\text{stride}[1]} + 1\right\rfloor \]
weight

the learnable weights of the module of shape \((\text{out\_channels}, \frac{\text{in\_channels}}{\text{groups}},\) \(\text{kernel\_size[0]}, \text{kernel\_size[1]})\). The values of these weights are sampled from \(\mathcal{U}(-\sqrt{k}, \sqrt{k})\) where \(k = \frac{1}{C_\text{in} * \prod_{i=0}^{1}\text{kernel\_size}[i]}\)

Type

Tensor

bias

the learnable bias of the module of shape (out_channels). If bias is True, then the values of these weights are sampled from \(\mathcal{U}(-\sqrt{k}, \sqrt{k})\) where \(k = \frac{1}{C_\text{in} * \prod_{i=0}^{1}\text{kernel\_size}[i]}\)

Type

Tensor

Examples:

>>> # With square kernels and equal stride
>>> m = nn.Conv2d(16, 33, 3, stride=2)
>>> # non-square kernels and unequal stride and with padding
>>> m = nn.Conv2d(16, 33, (3, 5), stride=(2, 1), padding=(4, 2))
>>> # non-square kernels and unequal stride and with padding and dilation
>>> m = nn.Conv2d(16, 33, (3, 5), stride=(2, 1), padding=(4, 2), dilation=(3, 1))
>>> input = torch.randn(20, 16, 50, 100)
>>> output = m(input)
bias: Optional[torch.Tensor]
dilation: Tuple[int, ...]
forward(input)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

groups: int
kernel_size: Tuple[int, ...]
out_channels: int
output_padding: Tuple[int, ...]
padding: Union[str, Tuple[int, ...]]
padding_mode: str
stride: Tuple[int, ...]
transposed: bool
weight: torch.Tensor

torchlib.module.layers.cnnsize module

torchlib.module.layers.cnnsize.ConvSize1d(CLi, Co, K, S, P, D=1, groups=1)

Compute shape after 2D-Convolution

(2)\[\begin{array}{l} L_{o} &= \left\lfloor\frac{L_{i} + 2 \times P_l - D_l \times (K_l - 1) - 1}{S_l} + 1\right\rfloor \\ \end{array} \]
CLi{tuple or list}

input data shape (C, L)

Co{integer number}

number of output chanels.

Ktuple

kernel size

Stuple

stride size

Ptuple

padding size

D{tuple}, optional

dilation size (the default is 1)

groupsint, optional

[description] (the default is 1, which [default_description])

Returns

shape after 2D-Convolution

Return type

tuple

Raises

ValueError – dilation should be greater than zero.

torchlib.module.layers.cnnsize.ConvSize2d(CHWi, Co, K, S, P, D=(1, 1), groups=1)

Compute shape after 2D-Convolution

(3)\[\begin{array}{l} H_{o} &= \left\lfloor\frac{H_{i} + 2 \times P_h - D_h \times (K_h - 1) - 1}{S_h} + 1\right\rfloor \\ W_{o} &= \left\lfloor\frac{W_{i} + 2 \times P_w - D_w \times (K_w - 1) - 1}{S_w} + 1\right\rfloor \end{array} \]
CHWi{tuple or list}

input data shape (C, H, W)

Co{integer number}

number of output chanels.

Ktuple

kernel size

Stuple

stride size

Ptuple

padding size

D{tuple}, optional

dilation size (the default is (1, 1))

groupsint, optional

[description] (the default is 1, which [default_description])

Returns

shape after 2D-Convolution

Return type

tuple

Raises

ValueError – dilation should be greater than zero.

torchlib.module.layers.cnnsize.ConvTransposeSize1d(CLi, Co, K, S, P, D=1, OP=0, groups=1)

Compute shape after Transpose Convolution

(4)\[\begin{array}{l} L_{o} &= (L_{i} - 1) \times S_l - 2 \times P_l + D_l \times (K_l - 1) + OP_l + 1 \\ \end{array} \]
Parameters
  • CLi ({tuple or list}) – input data shape (C, H, W)

  • Co ({integer number}) – number of output chanels.

  • K (tuple) – kernel size

  • S (tuple) – stride size

  • P (tuple) – padding size

  • D ({tuple}, optional) – dilation size (the default is 1)

  • OP ({tuple}, optional) – output padding size (the default is 0)

  • groups ({integer number}, optional) – one group (the default is 1)

Returns

shape after 2D-Transpose Convolution

Return type

tuple

Raises

ValueError – output padding must be smaller than either stride or dilation

torchlib.module.layers.cnnsize.ConvTransposeSize2d(CHWi, Co, K, S, P, D=(1, 1), OP=(0, 0), groups=1)

Compute shape after Transpose Convolution

(5)\[\begin{array}{l} H_{o} &= (H_{i} - 1) \times S_h - 2 \times P_h + D_h \times (K_h - 1) + OP_h + 1 \\ W_{o} &= (W_{i} - 1) \times S_w - 2 \times P_w + D_w \times (K_w - 1) + OP_w + 1 \end{array} \]
Parameters
  • CHWi ({tuple or list}) – input data shape (C, H, W)

  • Co ({integer number}) – number of output chanels.

  • K (tuple) – kernel size

  • S (tuple) – stride size

  • P (tuple) – padding size

  • D ({tuple}, optional) – dilation size (the default is (1, 1))

  • OP ({tuple}, optional) – output padding size (the default is (0, 0))

  • groups ({integer number}, optional) – one group (the default is 1)

Returns

shape after 2D-Transpose Convolution

Return type

tuple

Raises

ValueError – output padding must be smaller than either stride or dilation

torchlib.module.layers.cnnsize.PoolSize1d(CLi, K, S, P, D=1)
torchlib.module.layers.cnnsize.PoolSize2d(CHWi, K, S, P, D=(1, 1))
torchlib.module.layers.cnnsize.UnPoolSize1d(CLi, K, S, P, D=1)
torchlib.module.layers.cnnsize.UnPoolSize2d(CHWi, K, S, P, D=(1, 1))

torchlib.module.layers.complex_layers module

Created on Tue Mar 19 10:30:02 2019

@author: Sebastien M. Popoff

Based on https://openreview.net/forum?id=H1T2hmZAb

class torchlib.module.layers.complex_layers.ComplexBatchNorm1d(num_features, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)

Bases: torchlib.module.layers.complex_layers._ComplexBatchNorm

forward(input)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool
class torchlib.module.layers.complex_layers.ComplexBatchNorm2d(num_features, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)

Bases: torchlib.module.layers.complex_layers._ComplexBatchNorm

forward(input)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool
class torchlib.module.layers.complex_layers.ComplexConv1(axis, in_channels, out_channels, kernel_size=3, stride=1, padding=0, dilation=1, groups=1, bias=True, padding_mode='zeros')

Bases: torch.nn.modules.module.Module

forward(Xr, Xi)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool
class torchlib.module.layers.complex_layers.ComplexConv1d(in_channels, out_channels, kernel_size=3, stride=1, padding=0, dilation=1, groups=1, bias=True, padding_mode='zeros')

Bases: torch.nn.modules.module.Module

forward(input)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool
class torchlib.module.layers.complex_layers.ComplexConv2(in_channels, out_channels, kernel_size=3, stride=1, padding=0, dilation=1, groups=1, bias=True, padding_mode='zeros')

Bases: torch.nn.modules.module.Module

forward(Xr, Xi)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool
class torchlib.module.layers.complex_layers.ComplexConv2d(in_channels, out_channels, kernel_size=3, stride=1, padding=0, dilation=1, groups=1, bias=True, padding_mode='zeros')

Bases: torch.nn.modules.module.Module

forward(input)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool
class torchlib.module.layers.complex_layers.ComplexConvTranspose1d(in_channels, out_channels, kernel_size, stride=1, padding=0, output_padding=0, groups=1, bias=True, dilation=1, padding_mode='zeros')

Bases: torch.nn.modules.module.Module

forward(input)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool
class torchlib.module.layers.complex_layers.ComplexConvTranspose2d(in_channels, out_channels, kernel_size, stride=1, padding=0, output_padding=0, groups=1, bias=True, dilation=1, padding_mode='zeros')

Bases: torch.nn.modules.module.Module

forward(input)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool
class torchlib.module.layers.complex_layers.ComplexDropout(p=0.5, inplace=False)

Bases: torch.nn.modules.module.Module

forward(input)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool
class torchlib.module.layers.complex_layers.ComplexDropout2d(p=0.5, inplace=False)

Bases: torch.nn.modules.module.Module

forward(input)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool
class torchlib.module.layers.complex_layers.ComplexLeakyReLU(negative_slope=(0.01, 0.01), inplace=False)

Bases: torch.nn.modules.module.Module

forward(input)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool
class torchlib.module.layers.complex_layers.ComplexLinear(in_features, out_features)

Bases: torch.nn.modules.module.Module

forward(input)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool
class torchlib.module.layers.complex_layers.ComplexMaxPool1(axis, kernel_size, stride=None, padding=0, dilation=1, return_indices=False, ceil_mode=False)

Bases: torch.nn.modules.module.Module

forward(Xr, Xi)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool
class torchlib.module.layers.complex_layers.ComplexMaxPool1d(kernel_size, stride=None, padding=0, dilation=1, return_indices=False, ceil_mode=False)

Bases: torch.nn.modules.module.Module

forward(input)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool
class torchlib.module.layers.complex_layers.ComplexMaxPool2(kernel_size, stride=None, padding=0, dilation=1, return_indices=False, ceil_mode=False)

Bases: torch.nn.modules.module.Module

forward(Xr, Xi)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool
class torchlib.module.layers.complex_layers.ComplexMaxPool2d(kernel_size, stride=None, padding=0, dilation=1, return_indices=False, ceil_mode=False)

Bases: torch.nn.modules.module.Module

forward(input)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool
class torchlib.module.layers.complex_layers.ComplexReLU(inplace=False)

Bases: torch.nn.modules.module.Module

forward(input)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool
class torchlib.module.layers.complex_layers.ComplexSequential(*args: torch.nn.modules.module.Module)
class torchlib.module.layers.complex_layers.ComplexSequential(arg: OrderedDict[str, Module])

Bases: torch.nn.modules.container.Sequential

forward(input)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class torchlib.module.layers.complex_layers.ComplexSoftShrink(alpha=0.5, caxis=None, inplace=False)

Bases: torch.nn.modules.module.Module

forward(input, alpha=None)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool
class torchlib.module.layers.complex_layers.ComplexUpsample(size=None, scale_factor=None, mode='nearest', align_corners=None)

Bases: torch.nn.modules.module.Module

forward(input)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool
class torchlib.module.layers.complex_layers.NaiveComplexBatchNorm1d(num_features, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)

Bases: torch.nn.modules.module.Module

Naive approach to complex batch norm, perform batch norm independently on real and imaginary part.

forward(input)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool
class torchlib.module.layers.complex_layers.NaiveComplexBatchNorm2d(num_features, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)

Bases: torch.nn.modules.module.Module

Naive approach to complex batch norm, perform batch norm independently on real and imaginary part.

forward(input)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool
class torchlib.module.layers.complex_layers.SoftShrink(alpha=0.5, inplace=False)

Bases: torch.nn.modules.module.Module

forward(input, alpha=None)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool

torchlib.module.layers.consistency_layers module

class torchlib.module.layers.consistency_layers.DataConsistency2d(ftaxis=(- 2, - 1), mixrate=1.0, isfft=True)

Bases: torch.nn.modules.module.Module

forward(x, y, mask)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool

torchlib.module.layers.convolution module

class torchlib.module.layers.convolution.Conv1(axis, in_channels, out_channels, kernel_size=3, stride=1, padding=0, dilation=1, groups=1, bias=True, padding_mode='zeros')

Bases: torch.nn.modules.module.Module

forward(X)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool
class torchlib.module.layers.convolution.Conv2(in_channels, out_channels, kernel_size=3, stride=1, padding=0, dilation=1, groups=1, bias=True, padding_mode='zeros')

Bases: torch.nn.modules.module.Module

forward(X)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool
class torchlib.module.layers.convolution.FFTConv1(nh, h=None, axis=0, nfft=None, shape='same', train=True)

Bases: torch.nn.modules.module.Module

forward(x)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool
class torchlib.module.layers.convolution.MaxPool1(axis, kernel_size, stride=None, padding=0, dilation=1, return_indices=False, ceil_mode=False)

Bases: torch.nn.modules.module.Module

forward(X)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool
class torchlib.module.layers.convolution.MaxPool2(kernel_size, stride=None, padding=0, dilation=1, return_indices=False, ceil_mode=False)

Bases: torch.nn.modules.module.Module

forward(X)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool

torchlib.module.layers.edge module

class torchlib.module.layers.edge.EdgeDetector

Bases: torch.nn.modules.module.Module

forward(image)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool
class torchlib.module.layers.edge.EdgeFeatureExtractor(Ci)

Bases: torch.nn.modules.module.Module

forward(x)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool

torchlib.module.layers.fft_layers module

class torchlib.module.layers.fft_layers.FFTLayer1d(nfft=None)

Bases: torch.nn.modules.module.Module

forward(x)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool

torchlib.module.layers.flow_layers module

class torchlib.module.layers.flow_layers.ActNorm(inchannels, logdet=True)

Bases: torch.nn.modules.module.Module

forward(input)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

initialize(input)
reverse(output)
training: bool
class torchlib.module.layers.flow_layers.AffineCoupling(inchannels, filter_size=512, affine=True)

Bases: torch.nn.modules.module.Module

forward(input)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

reverse(output)
training: bool
class torchlib.module.layers.flow_layers.Flow(inchannels, affine=True, convlu=True)

Bases: torch.nn.modules.module.Module

forward(input)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

reverse(output)
training: bool
class torchlib.module.layers.flow_layers.FlowBlock(inchannels, nflow, split=True, affine=True, convlu=True)

Bases: torch.nn.modules.module.Module

forward(input)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

reverse(output, eps=None, reconstruct=False)
training: bool
class torchlib.module.layers.flow_layers.Glow(inchannels, nflow, nblock, affine=True, convlu=True)

Bases: torch.nn.modules.module.Module

forward(input)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

reverse(z_list, reconstruct=False)
training: bool
class torchlib.module.layers.flow_layers.InvConv2d(inchannels)

Bases: torch.nn.modules.module.Module

forward(input)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

reverse(output)
training: bool
class torchlib.module.layers.flow_layers.InvConv2dLU(inchannels)

Bases: torch.nn.modules.module.Module

calc_weight()
forward(input)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

reverse(output)
training: bool
class torchlib.module.layers.flow_layers.ZeroConv2d(inchannels, out_channel, padding=1)

Bases: torch.nn.modules.module.Module

forward(input)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool
torchlib.module.layers.flow_layers.gaussian_log_p(x, mean, log_sd)
torchlib.module.layers.flow_layers.gaussian_sample(eps, mean, log_sd)
torchlib.module.layers.flow_layers.logabs(x)

torchlib.module.layers.gaborconv2d module

class torchlib.module.layers.gaborconv2d.GaborConv2d(channel_in, channel_out, kernel_size, stride=1, padding=0)

Bases: torch.nn.modules.module.Module

forward(x)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool
torchlib.module.layers.gaborconv2d.gabor_fn(kernel_size, channel_in, channel_out, sigma, theta, Lambda, psi, gamma)

torchlib.module.layers.phase_convolution module

class torchlib.module.layers.phase_convolution.ComplexPhaseConv1d(in_channels, out_channels, kernel_size=3, stride=1, padding=0, dilation=1, groups=1, bias=None, padding_mode='zeros')

Bases: torch.nn.modules.module.Module

forward(x)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool
class torchlib.module.layers.phase_convolution.ComplexPhaseConv2d(in_channels, out_channels, kernel_size=3, stride=1, padding=0, dilation=1, groups=1, bias=None, padding_mode='zeros')

Bases: torch.nn.modules.module.Module

forward(x)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool
class torchlib.module.layers.phase_convolution.ComplexPhaseConvTranspose1d(in_channels, out_channels, kernel_size, stride=1, padding=0, output_padding=0, groups=1, bias=None, dilation=1, padding_mode='zeros')

Bases: torch.nn.modules.module.Module

forward(x)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool
class torchlib.module.layers.phase_convolution.ComplexPhaseConvTranspose2d(in_channels, out_channels, kernel_size, stride=1, padding=0, output_padding=0, groups=1, bias=None, dilation=1, padding_mode='zeros')

Bases: torch.nn.modules.module.Module

forward(x)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool
class torchlib.module.layers.phase_convolution.PhaseConv1d(in_channels, out_channels, kernel_size=3, stride=1, padding=0, dilation=1, groups=1, bias=None, padding_mode='zeros')

Bases: torch.nn.modules.module.Module

forward(x)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool
class torchlib.module.layers.phase_convolution.PhaseConv2d(in_channels, out_channels, kernel_size=3, stride=1, padding=0, dilation=1, groups=1, bias=None, padding_mode='zeros')

Bases: torch.nn.modules.module.Module

forward(x)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool
class torchlib.module.layers.phase_convolution.PhaseConvTranspose1d(in_channels, out_channels, kernel_size, stride=1, padding=0, output_padding=0, groups=1, bias=None, dilation=1, padding_mode='zeros')

Bases: torch.nn.modules.module.Module

forward(x)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool
class torchlib.module.layers.phase_convolution.PhaseConvTranspose2d(in_channels, out_channels, kernel_size, stride=1, padding=0, output_padding=0, groups=1, bias=None, dilation=1, padding_mode='zeros')

Bases: torch.nn.modules.module.Module

forward(x)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool

torchlib.module.layers.pool module

class torchlib.module.layers.pool.MeanSquarePool2d(kernel_size, stride=None, padding=0, ceil_mode=False, count_include_pad=True)

Bases: torch.nn.modules.module.Module

forward(x)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool
class torchlib.module.layers.pool.PnormPool2d(kernel_size, p=2, stride=None, padding=0, ceil_mode=False, count_include_pad=True)

Bases: torch.nn.modules.module.Module

forward(x)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool

Module contents