rosinality/alias-free-gan-pytorch

about input fourier features.

lzhbrian opened this issue · 0 comments

Hi, thanks for the work. I have a question regarding the input fourier features.
I think you might have included the margin into the target canvas (-0.5~0.5) ?
That makes the input frequencies become relatively lower.

class FourierFeature(nn.Module):
def __init__(self, size, dim, cutoff, eps=1e-8):
super().__init__()
coords = torch.linspace(-0.5, 0.5, size + 1)[:-1]
freqs = torch.linspace(0, cutoff, dim // 4)

A possible fix would be something like:

class FourierFeature(nn.Module):
    def __init__(self, size=16, margin=10, dim=512, cutoff=2, eps=1e-8):
        """
        size:   sampling rate (or feature map size)
        margin: expanded feature map margin size
        dim:    # channels
        cutoff: cutoff fc
        """
        super().__init__()

        normalized_margin = margin / size
        # -0.5-m ~ 0.5+m, uniform interplate 'size' (except the last one)
        # note the margin here, target canvas was -0.5~0.5, extended canvas should be larger
        coords = torch.linspace(- 0.5 - normalized_margin, 
                                  0.5 + normalized_margin, 
                                size + 2 * margin + 1)[:-1]