MCPcopy Create free account
hub / github.com/Standard-Intelligence/hertz-dev / NonCausalConv1d

Class NonCausalConv1d

tokenizer.py:21–60  ·  view source on GitHub ↗

1D noncausal convolution w/ 2-sides padding.

Source from the content-addressed store, hash-verified

19
20
21class NonCausalConv1d(nn.Module):
22 """1D noncausal convolution w/ 2-sides padding."""
23
24 def __init__(
25 self,
26 in_channels,
27 out_channels,
28 kernel_size,
29 stride=1,
30 padding=-1,
31 dilation=1,
32 groups=1,
33 bias=True):
34 super().__init__()
35 self.in_channels = in_channels
36 self.out_channels = out_channels
37 self.kernel_size = kernel_size
38 if padding < 0:
39 padding = (kernel_size - 1) // 2 * dilation
40 self.dilation = dilation
41 self.conv = nn.Conv1d(
42 in_channels=in_channels,
43 out_channels=out_channels,
44 kernel_size=kernel_size,
45 stride=stride,
46 padding=padding,
47 dilation=dilation,
48 groups=groups,
49 bias=bias,
50 )
51
52 def forward(self, x):
53 """
54 Args:
55 x (Tensor): Float tensor variable with the shape (B, C, T).
56 Returns:
57 Tensor: Float tensor variable with the shape (B, C, T).
58 """
59 x = self.conv(x)
60 return x
61
62
63class NonCausalConvTranspose1d(nn.Module):

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected