Comments (7)
Positional encoding concatenates 2 extra values (an x, y coordinate) to the input channels. So, if you have 10 input channels, you'll have 12 after positional encoding.
Imagine you have a 2D spatial domain measuring 64x64 samples. Run this code real quick (shamelessly stolen from numpy's meshgrid reference) and take a look at the 2x64x64 matrix that is produced:
import numpy as np
nx, ny = (64, 64)
x = np.linspace(0, 1, nx)
y = np.linspace(0, 1, ny)
xv, yv = np.meshgrid(x, y)
grid = np.stack((xv, yv))
The 2 layers of the matrix are the x and y coords. Imagine appending this matrix to the end of your input data. There's your positional encoding!
As for what it does, it helps improve convergence by a noticeable margin from my experiments so far. From what I understand, this is because it gives the FNO a constant reference to grid positions regardless of the physical activity that's happening. This produces more consistent signal spectra in the Fourier layers, hence the improved convergence. But I'm not entirely sure myself so that's just my best guess :)
from neuraloperator.
Positional embedding is critical if you want to do super-resolution and want to provide arbitrary positions of query points
from neuraloperator.
@itskobold Thanks for your reply.
Does this mean that data without Positional Encoding is less accurate than data with Positional Encoding because more explicit positional information is not input at the input layer?
Am I correct in assuming that the grid position here refers to physical quantities within the grid points, such as pressure, flow velocity, vorticity, etc.?
from neuraloperator.
Hi @furankaeru, no problem & apologies for the late reply -
From my experiments, positional encoding has improved network convergence every time by a significant (but not huge) margin. I would say yes, from my understanding, positional encoding improves network convergence because it provides explicit positional information to the FNO.
Your assumption is correct; the grid points concatenated to your input data is extra constant data that "underlies" the physical activity you're modelling regardless of what it is.
from neuraloperator.
@itskobold Thanks for your reply.
I see, that makes sense.
Thank you for taking the time to answer my questions.
from neuraloperator.
Sorry, I had one more question.
Is positional encoding available for Navier-Stokes equations?
From reading the documentation, it doesn't seem to say anything about data loading and positional encoding for the Navier-Stokes equations?
Could you give me a sample code to use positional encoding with the Navier-Stokes equations?
from neuraloperator.
Closing as resolved
from neuraloperator.
Related Issues (20)
- Bayesian Inverse Problems HOT 1
- FNO for complex-valued spatial data
- NS dataset question HOT 2
- .\neuraloperator\neuralop\training\callbacks.py error HOT 3
- OutputEncoderCallback problem HOT 3
- Inverse Problem in FNO HOT 2
- RuntimeError: The size of tensor a (2) must match the size of tensor b (16) at non-singleton dimension 3 HOT 1
- RuntimeError: The size of tensor a (2) must match the size of tensor b (16) at non-singleton dimension 3
- Fixing gradient backprop in #233
- MLP dropout > 0.5 causes error HOT 1
- DDP wireup requires calling from MPI
- import error in Training a TFNO on Darcy-Flow example HOT 1
- Training the neural operator in 3D spatial domain HOT 3
- Reproducing the published results
- Potential models to implement and merge
- Reproducing GINO
- loss sometimes jumps at restart
- How to create darcy dataset on different resolution? HOT 1
- U-NO on Darcy-Flow (Gallery of example) don't run on cuda
- [Request] Dataset creation and acquisiton documentation HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from neuraloperator.