Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

about input fourier features. #24

Open
lzhbrian opened this issue Sep 18, 2021 · 0 comments
Open

about input fourier features. #24

lzhbrian opened this issue Sep 18, 2021 · 0 comments

Comments

@lzhbrian
Copy link

lzhbrian commented Sep 18, 2021

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]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant