| 113 | |
| 114 | |
| 115 | class Decoder(nn.Module): |
| 116 | def __init__( |
| 117 | self, |
| 118 | input_channel, |
| 119 | channels, |
| 120 | rates, |
| 121 | d_out: int = 1, |
| 122 | ): |
| 123 | super().__init__() |
| 124 | |
| 125 | # Add first conv layer |
| 126 | layers = [WNConv1d(input_channel, channels, kernel_size=7, padding=3)] |
| 127 | |
| 128 | # Add upsampling + MRF blocks |
| 129 | for i, stride in enumerate(rates): |
| 130 | input_dim = channels // 2**i |
| 131 | output_dim = channels // 2 ** (i + 1) |
| 132 | layers += [DecoderBlock(input_dim, output_dim, stride)] |
| 133 | |
| 134 | # Add final conv layer |
| 135 | layers += [ |
| 136 | Snake1d(output_dim), |
| 137 | WNConv1d(output_dim, d_out, kernel_size=7, padding=3), |
| 138 | nn.Tanh(), |
| 139 | ] |
| 140 | |
| 141 | self.model = nn.Sequential(*layers) |
| 142 | |
| 143 | def forward(self, x): |
| 144 | return self.model(x) |
| 145 | |
| 146 | |
| 147 | class DAC(BaseModel, CodecMixin): |