-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Adding example on Physics-Informed Neural Networks for solving Eikonal equation #1345
base: master
Are you sure you want to change the base?
Conversation
…g Eikonal equation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
examples/pinn/eikonal.py
Outdated
two-point modification of the [eikonal | ||
equation](https://en.wikipedia.org/wiki/Eikonal_equation): | ||
|
||
$$\Vert \nabla_r \tau(\textbf{x}_s, \textbf{x}_r) \Vert = \frac{1}{v(\textbf{x}_r)}$$ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't use latex syntax. Either explain equations via python code snippets or pseudocode snippets, or include rendered images of equations. The former is better since it is more accessible to our audience.
examples/pinn/eikonal.py
Outdated
@@ -0,0 +1,459 @@ | |||
""" | |||
Title: Neural Eikonal Solver |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not create a new category specifically for this example. Is there an existing category that could be a good fit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
best fit would be "quick keras recipes" perhaps; though PINNs probably don't fit in there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your comments and reply!
I was also thinking about "quick keras recipes" but alternatively since eikonal is widely used in computer vision if I adapt the example to a computer vision context (e.g. to Shape-from-Shading problem), do you think that "computer vision" could be a good fit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I say we put it in quick keras recipes and focus on the concept of PINNs!
I think we should emphasize that in PINNs you simply add an L2 loss to enforce the implicit physics constraints of the system.
examples/pinn/eikonal.py
Outdated
|
||
def build_model(input_scale, vmin, vmax, dim=2): | ||
# Hyperparameters | ||
n_layers = 5 # number of hidden layers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naming nit: use num_
as number prefix.
examples/pinn/eikonal.py
Outdated
inputs_list = xs_list + xr_list | ||
|
||
# Scaling of inputs, to avoid unit dependence | ||
XsXr = Concatenate(name="x", axis=-1)([xs, xr]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naming nit: use snake case for all instances. Lowercase.
examples/pinn/eikonal.py
Outdated
xr = Concatenate(name="xr", axis=-1)(xr_list) | ||
|
||
# Input 3: velocity model at Receiver coordinates | ||
vr = Input(shape=(1,), name="vr") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naming tips: strictly avoid non-obvious one-letter or two-letter names. Use fully-spelled out variable names everywhere.
examples/pinn/eikonal.py
Outdated
|
||
import tensorflow as tf | ||
from tensorflow.keras.layers.experimental.preprocessing import Rescaling | ||
from tensorflow.keras.layers import Input, Concatenate, Dense |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just from tensorflow.keras import layers
, then access elements of the module, e.g. layers.Dense
examples/pinn/eikonal.py
Outdated
from tensorflow.keras.layers.experimental.preprocessing import Rescaling | ||
from tensorflow.keras.layers import Input, Concatenate, Dense | ||
from tensorflow.keras.layers import Multiply, Subtract, Lambda | ||
from tensorflow.keras.models import Model |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Access it from keras
examples/pinn/eikonal.py
Outdated
## Imports | ||
""" | ||
|
||
import tensorflow as tf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also import keras
Hello, |
Hello,
According to my question, you might be interested in a new example of physics-informed neural networks (PINNs).
I created a new folder
pinn
in the repo since it did not have any related to physics-informed neural networks (pinn)This
.py
file contains the example with the neural eikonal solver.Serafim