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

Class NonCausalConvTranspose1d

tokenizer.py:63–101  ·  view source on GitHub ↗

1D noncausal transpose convolution.

Source from the content-addressed store, hash-verified

61
62
63class 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
104class CausalConv1d(NonCausalConv1d):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected