1D noncausal transpose convolution.
| 61 | |
| 62 | |
| 63 | class NonCausalConvTranspose1d(nn.Module): |
| 64 | """1D noncausal transpose convolution.""" |
| 65 | |
| 66 | def __init__( |
| 67 | self, |
| 68 | in_channels, |
| 69 | out_channels, |
| 70 | kernel_size, |
| 71 | stride, |
| 72 | padding=-1, |
| 73 | output_padding=-1, |
| 74 | groups=1, |
| 75 | bias=True, |
| 76 | ): |
| 77 | super().__init__() |
| 78 | if padding < 0: |
| 79 | padding = (stride+1) // 2 |
| 80 | if output_padding < 0: |
| 81 | output_padding = 1 if stride % 2 else 0 |
| 82 | self.deconv = nn.ConvTranspose1d( |
| 83 | in_channels=in_channels, |
| 84 | out_channels=out_channels, |
| 85 | kernel_size=kernel_size, |
| 86 | stride=stride, |
| 87 | padding=padding, |
| 88 | output_padding=output_padding, |
| 89 | groups=groups, |
| 90 | bias=bias, |
| 91 | ) |
| 92 | |
| 93 | def forward(self, x): |
| 94 | """ |
| 95 | Args: |
| 96 | x (Tensor): Float tensor variable with the shape (B, C, T). |
| 97 | Returns: |
| 98 | Tensor: Float tensor variable with the shape (B, C', T'). |
| 99 | """ |
| 100 | x = self.deconv(x) |
| 101 | return x |
| 102 | |
| 103 | |
| 104 | class CausalConv1d(NonCausalConv1d): |
nothing calls this directly
no outgoing calls
no test coverage detected