CoolFace
Modelpublic

mlr2000/vocoder-large

sourceHugging Facecc-by-4.0updated 2mo agoView on Hugging Face
0likes38downloads
alias_free_act.py31 linesDownload Raw Back to root
1# Adapted from https://github.com/junjun3518/alias-free-torch under the Apache License 2.02#   LICENSE is in incl_licenses directory.3 4import torch.nn as nn5from .alias_free_resample import UpSample1d, DownSample1d6 7 8class Activation1d(nn.Module):9    def __init__(10        self,11        activation,12        up_ratio: int = 2,13        down_ratio: int = 2,14        up_kernel_size: int = 12,15        down_kernel_size: int = 12,16    ):17        super().__init__()18        self.up_ratio = up_ratio19        self.down_ratio = down_ratio20        self.act = activation21        self.upsample = UpSample1d(up_ratio, up_kernel_size)22        self.downsample = DownSample1d(down_ratio, down_kernel_size)23 24    # x: [B,C,T]25    def forward(self, x):26        x = self.upsample(x)27        x = self.act(x)28        x = self.downsample(x)29 30        return x31