benmoseley / harmonic-oscillator-pinn Goto Github PK
View Code? Open in Web Editor NEWCode accompanying my blog post: So, what is a physics-informed neural network?
License: MIT License
Code accompanying my blog post: So, what is a physics-informed neural network?
License: MIT License
Hi, first of all congratulations for the very nice work, the blog-post and the code, I enjoyed them very much!
Not a real issue here, just wanted to share what I found playing around with the code and I think could be interesting.
So basically I restricted the range of x_physiscs , i.e. the range where the physics loss is evaluated, to a smaller interval (e.g. [0,0.6] to see whether the network was able to generalize beyond training data.
Here is what I get:
So in my understanding the network is not learning the solution of the differential equation, but only a polynomial approximation which fits the training data only in a specific range. Thus if you would like to use the network to make predictions, you have to make sure that the training data points for the physics loss do cover the range you would like to predict.
This raises another possible issue, i.e. describing many oscillations of the system may require very high order polynomials and this could go beyond the expressive power of the NN. In the spirit of "physics informed networks" maybe some priors on the solutions could be used to engineer a network which indeed has the capability of parameterize the exact solution, such as periodic activation functions, to mention one.
Best,
P.
Hello, your work is very impressive and I learned a lot from it, thank you!
Here I have one question about loss2. I noticed that the loss2 is mutiply by 1e-4, I can understand you want to make the training faster, but may I ask why you choose this number and do you have any experience and this figure?
Another question is about the initial conditions, you didn't show them explicit in the code, does it means we do not need to think about these conditions when we use PINN for ODEs?
Hello Ben,
how would you tackle the whole thing if you determine the next position and velocity with the Euler method? This approach is mainly used to simulate physics in video games and produces an approximate discrete solution by iterating position and velocity. Here, b is the damping, which is typically between 0 and 1, and d is the position in force equilibrium.
function step(x_0, v_0) {
a_spring = k * (d - x_0)
v_1 = b * v_0 + a_spring * delta_t
x_1 = x_0 + v_1 * delta_t
return [x_1, v_1]
}
What I would like to get in the end is a neural network that does the following:
x_n+1, v_n+1 = NN(x_n, v_n)
I think I would treat it essentially like a time series forecasting but how would I formulate the "physics loss"?
Hello and great contribution!
I'm want to make sure of how to expand the current example to 2D instead of 1D (even further 2D + 1D for time). I assume that in the code, I need to change:
It does seem to be straightforward as I have faced errors when doing this. A 2D example would be hugely helpful.
Thanks!
In actual problem, I have only data can this be used to discover all the parameters?
I tried using k and mu as unknown parameters but solution dont converge.
Hello Ben,
For the given differential equation, what if we do not have the analytical solution...
Then we do not have those data points (x_data, y_data) by which we have got loss_1, and if we train our model only by physics-based loss "loss_2", we won't get accurate results.
In Raissi et. al. paper on PINNs, they have taken the loss_1 term corresponding to the boundary and initial conditions.
So can we get an accurate result for the given differential equation(1 SDOF) if we incorporate the two initial conditions given in the question in the loss
and not the data points we have taken from the analytical solution of the differential equation?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.