| 770 | |
| 771 | |
| 772 | class Decoder(nn.Module): |
| 773 | def __init__( |
| 774 | self, |
| 775 | input_channel, |
| 776 | channels, |
| 777 | rates, |
| 778 | d_out: int = 1, |
| 779 | ): |
| 780 | super().__init__() |
| 781 | |
| 782 | # Add first conv layer |
| 783 | layers = [WNConv1d(input_channel, channels, kernel_size=7, padding=3)] |
| 784 | |
| 785 | # Add upsampling + MRF blocks |
| 786 | for i, stride in enumerate(rates): |
| 787 | input_dim = channels // 2**i |
| 788 | output_dim = channels // 2 ** (i + 1) |
| 789 | layers += [DecoderBlock(input_dim, output_dim, stride)] |
| 790 | |
| 791 | # Add final conv layer |
| 792 | layers += [ |
| 793 | Snake1d(output_dim), |
| 794 | WNConv1d(output_dim, d_out, kernel_size=7, padding=3), |
| 795 | nn.Tanh(), |
| 796 | ] |
| 797 | |
| 798 | self.model = nn.Sequential(*layers) |
| 799 | |
| 800 | def forward(self, x): |
| 801 | return self.model(x) |
| 802 | |
| 803 | |
| 804 | class DAC(BaseModel, CodecMixin): |