r/MachineLearning • u/jnbrrn • Jun 19 '20
Research [R] Fourier Features Let Networks Learn High Frequency Functions in Low Dimensional Domains
Hi /ml, I'm one of the authors of NeRF, which you might have seen going around a few months ago (https://matthewtancik.com/nerf). We were confused and amazed by how effective the "positional encoding" trick was for NeRF, as were many other people. So we spent the last three months figuring out what was making this thing tick. I think we've figured it out, but I'm eager to get more feedback from the community.
In short: Neural networks have a "spectral bias" towards being smooth, and this bias is severe when the input to the network is low dimensional (like a 3D coordinate in space, or a 2D coordinate in an image). Neural Tangent Kernel theory lets you figure out why this is happening: the network's kernel is fundamentally bad at interpolation, in a basic signal processing sense. But this simple trick of projecting your input points onto a random Fourier basis results in a "composed" network kernel that makes sense for interpolation, and (as per basic signal processing) this gives you a network that is *much* better at interpolation-like tasks. You can even control the bandwidth of that kernel by varying the scale of the basis, which corresponds neatly to underfitting or overfitting. This simple trick combined with a very boring neural network works surprisingly well for a ton of tasks: image interpolation, 3D occupancy, MRI, CT, and of course NeRF.
Project page: https://people.eecs.berkeley.edu/~bmild/fourfeat/
39
u/PauloFalcao Jun 19 '20
A recent paper also proposed "SIREN, a simple neural network architecture for implicit neural representations that uses the sine as a periodic activation function: called SIREN "sinusoidal representation networks"" - https://arxiv.org/pdf/2006.09661.pdf
14
u/DTRademaker Jun 20 '20
Thank you so much!!! Two years ago I played a lot with these coordinate based MLPs (mostly for image denoising purposes and compressing videos) but it took days of training huge networks to get something 'nice', and only if there was not too much details in the data. I was always mesmerized about the results of the mathematical function the MLP learned by treating the pixels as random samples from a 'true' photo distribution. These results always seem other-worldly especially when you try to model high frequency data such as hair.
I can now continue experimenting, you made me a happy man today!
Created a simple pytorch class based on your paper, plugged it in my old code, and now it takes only minutes and the results are beautiful!
for people working with pytorch:
4
u/adamcrume Jun 20 '20
This looks very related to research I did for my thesis a few years ago:
- Fourier-Assisted Machine Learning of Hard Disk Drive Access Time Models http://www.pdsw.org/pdsw13/papers/p45-pdsw13-crume.pdf
- Latent Frequency Synthesis for Behavioral Hard Disk Drive Access Time Models https://pdfs.semanticscholar.org/7012/cbb3c06e6010ad1059004d9a18c23b329a24.pdf
- Automatic Learning of Block Storage Access Time Models (thesis) https://escholarship.org/content/qt9gs8x5n8/qt9gs8x5n8.pdf
4
u/zzzthelastuser Student Jun 20 '20
Aside from the obviously interesting scientific content, can we appreciate how fucking cool the presentation is?
I love the project page with all the plots, visualizations and animations. Many people take it for granted, but I guess a lot of work was put into that as well.
3
u/VishDev Jun 20 '20
Pardon my ignorance, but as I see it there are two things at play, the representation power of the network and our ability to find good parameters. If performing a feature transform yields lower error, shouldn’t the network be able to figure it out? Isn’t this the promise of feature learning?
So in this case, is it that the functional representation is expressive enough but optimization cannot find good parameters, or the representation power of the network is inherently limited and no oracle optimizer can solve this problem? I am hoping it is the latter.
2
u/[deleted] Jun 20 '20
Awesome work & great paper, congratulations! I've found similar properties for a fixed mapping of 2D inputs with random projections and sine/cosine functions to in the past, it definitely works nicely, even for LSH purposes after binarization.
Did you try higher dimensionalities than 3D? It would be interesting to investigate when this stops being beneficial. Intuitively, the scale of inputs should be inversely proportional to the dimensionality - this would degenerate to an identity mapping for high dimensions.
16
u/PauloFalcao Jun 19 '20
" We were confused and amazed by how effective the "positional encoding" trick was for NeRF " yap :)
1
u/purplebrown_updown Jun 20 '20
This is really interesting. The randomness is cool and I would like to understand it more. Just To understand the example on the website, is v two dimensional and B a nx2 matrix where n is the projected high dimensional space? Also, in this example the neural network takes in a pixel position and returns a three dimensional RGB output? Lastly, is B randomly chosen once for all pixels or is it different for each pixel?
1
u/mesmer_adama Jun 20 '20
Super nice work! Could you condition the MLP on either classes or the output from another image classifier to create a generative network?
5
u/Stepfunction Jun 19 '20
This is really great work! Having the experiments in Colab notebooks is a nice touch.
5
u/Mulcyber Jun 19 '20
I wonder if that would help the VAE that have a tendancy to reconstruct smooth outputs.
4
u/EEtoday Jun 20 '20
Very nice!
What exactly does this mean?
2
u/[deleted] Jun 20 '20
I’m a non expert. As far as I know a Fourier transform basically gives you a the relative power of the frequencies in an image. Are you somehow explicitly adding this information to the network? I’m surprised these networks don’t always learn some aspect of the power spectrum on their own. Are you basically trying to get the network to focus on the most information dense or predictive frequencies?
2
u/Vermeille Jun 20 '20
have you tried implementing this for GANs latent spaces?