Deep learning library for solving differential equations and more

Overview

DeepXDE

Build Status Documentation Status Codacy Badge PyPI Version PyPI Downloads Conda Version Conda Downloads License

Voting on whether we should have a Slack channel for discussion.

DeepXDE is a library for scientific machine learning. Use DeepXDE if you need a deep learning library that

  • solves forward and inverse partial differential equations (PDEs) via physics-informed neural network (PINN),
  • solves forward and inverse integro-differential equations (IDEs) via PINN,
  • solves forward and inverse fractional partial differential equations (fPDEs) via fractional PINN (fPINN),
  • approximates nonlinear operators via deep operator network (DeepONet),
  • approximates functions from multi-fidelity data via multi-fidelity NN (MFNN),
  • approximates functions from a dataset with/without constraints.

DeepXDE supports three tensor libraries as backends: TensorFlow 1.x (tensorflow.compat.v1 in TensorFlow 2.x), TensorFlow 2.x, and PyTorch. For how to select one, see Working with different backends.

Documentation: ReadTheDocs, SIAM Rev., Slides, Video

Papers on algorithms

Features

DeepXDE has implemented many algorithms as shown above and supports many features:

  • complex domain geometries without tyranny mesh generation. The primitive geometries are interval, triangle, rectangle, polygon, disk, cuboid, and sphere. Other geometries can be constructed as constructive solid geometry (CSG) using three boolean operations: union, difference, and intersection.
  • multi-physics, i.e., (time-dependent) coupled PDEs.
  • 5 types of boundary conditions (BCs): Dirichlet, Neumann, Robin, periodic, and a general BC, which can be defined on an arbitrary domain or on a point set.
  • different neural networks, such as (stacked/unstacked) fully connected neural network, residual neural network, and (spatio-temporal) multi-scale fourier feature networks.
  • 6 sampling methods: uniform, pseudorandom, Latin hypercube sampling, Halton sequence, Hammersley sequence, and Sobol sequence. The training points can keep the same during training or be resampled every certain iterations.
  • conveniently save the model during training, and load a trained model.
  • uncertainty quantification using dropout.
  • many different (weighted) losses, optimizers, learning rate schedules, metrics, etc.
  • callbacks to monitor the internal states and statistics of the model during training, such as early stopping.
  • enables the user code to be compact, resembling closely the mathematical formulation.

All the components of DeepXDE are loosely coupled, and thus DeepXDE is well-structured and highly configurable. It is easy to customize DeepXDE to meet new demands.

Installation

DeepXDE requires one of the following backend-specific dependencies to be installed:

Then, you can install DeepXDE itself.

  • Install the stable version with pip:
$ pip install deepxde
  • Install the stable version with conda:
$ conda install -c conda-forge deepxde
  • For developers, you should clone the folder to your local machine and put it along with your project scripts.
$ git clone https://github.com/lululxvi/deepxde.git

Explore more

Cite DeepXDE

If you use DeepXDE for academic research, you are encouraged to cite the following paper:

@article{lu2021deepxde,
  author  = {Lu, Lu and Meng, Xuhui and Mao, Zhiping and Karniadakis, George Em},
  title   = {{DeepXDE}: A deep learning library for solving differential equations},
  journal = {SIAM Review},
  volume  = {63},
  number  = {1},
  pages   = {208-228},
  year    = {2021},
  doi     = {10.1137/19M1274067}
}

Also, if you would like your paper to appear here, open an issue in the GitHub "Issues" section.

Contributing to DeepXDE

First off, thanks for taking the time to contribute!

  • Reporting bugs. To report a bug, simply open an issue in the GitHub "Issues" section.
  • Suggesting enhancements. To submit an enhancement suggestion for DeepXDE, including completely new features and minor improvements to existing functionality, let us know by opening an issue.
  • Pull requests. If you made improvements to DeepXDE, fixed a bug, or had a new example, feel free to send us a pull-request.
  • Asking questions. To get help on how to use DeepXDE or its functionalities, you can as well open an issue.
  • Answering questions. If you know the answer to any question in the "Issues", you are welcomed to answer.

The Team

DeepXDE was originally developed by Lu Lu at Brown University under the supervision of Prof. George Karniadakis from 2018 to 2020, supported by PhILMs.

DeepXDE is currently maintained by Lu Group at University of Pennsylvania with major contributions coming from several talented individuals in various forms and means. A non-exhaustive but growing list needs to mention: Shunyuan Mao, Zongren Zou.

License

Apache license 2.0

Comments
  • How to fit multivariate functions or perform data fitting by means of the FNN in Deepxde?

    How to fit multivariate functions or perform data fitting by means of the FNN in Deepxde?

    Hello @lululxvi , I find your package is very powerful, which can do many things on deep learning, such as fitting data which is simpler than solving and learning PDE, regression analysis of data and so on. Therefore, I would like to try to fit multivariate functions, for example, the function is f(x,t)=sin(x)sin(t). The data is provided as follow: Nx=11 , Nt=11 Xx=np.linspace(0,1,Nx) Tt=np.linspace(0,1,Nt) INt=np.ones(Nt) X=np.kron(INt,Xx) INx=np.ones(Nx) T=np.kron(Tt,INx) Input_data=np.array([X,T]) Label_data=np.sin(X)np.sin(T) noise_data=0.02tf.random.normal(shape=[NxNt]) Label_data=Label_data+noise_data data=np.array([Input_data,Label_data]). However, I am not good at tensorflow and python, I tried it, and didn't make it. Please help me ,how to revise it. Thank you very much. My code is : `from future import absolute_import from future import division from future import print_function

    import numpy as np

    import deepxde as dde from deepxde.backend import tf

    def main(): Nx=11 Nt=11 Xx=np.linspace(0,1,Nx) Tt=np.linspace(0,1,Nt) INt=np.ones(Nt) X=np.kron(INt,Xx) INx=np.ones(Nx) T=np.kron(Tt,INx) Input_data=np.array([X,T]) Label_data=np.sin(X)np.sin(T) noise_data=0.02tf.random.normal(shape=[Nx*Nt]) Label_data=Label_data+noise_data data=np.array([Input_data,Label_data]) layer_size = [2] + [50] * 3 + [1] activation = "tanh" initializer = "Glorot uniform" net = dde.maps.FNN(layer_size, activation, initializer)

    model = dde.Model(data, net)
    
    model.compile("adam", lr=0.001, metrics=["l2 relative error"])
    losshistory, train_state = model.train(epochs=10000)
    
    dde.saveplot(losshistory, train_state, issave=True, isplot=True)
    

    if name == "main": main()`

    opened by zxw4688 58
  • Shallow Water Equations and Riemann Problems

    Shallow Water Equations and Riemann Problems

    Hello Lu Lu, DeepXDE is great and I am trying to use it to deal with a complex Dam Break problem, that is:

    • Length = 10 m
    • Height Left = 0.005 m
    • Height Right = 0.001 m
    • The dam is at x = 5 m
    • Time = 6 s

    The 2D Shallow Water system I wrote is a pure hyperbolic problem without any sort of laplacian contribution or viscosity.

    I set up the training points only with the anchors, so that I can control the interval in every dimension:

    • Interval along x = 0.02
    • Interval along t = 0.02

    that results in 150,801 training points.

    The NN is a 2 + [40]*8 + 2 architecture trained with adam and 10000 epochs. Then it takes only 13 steps with L-BFGS-B and I get the message:

    INFO:tensorflow:Optimization terminated with:

    Message: b'CONVERGENCE: NORM_OF_PROJECTED_GRADIENT_<=_PGTOL' Objective function value: 0.000000 Number of iterations: 11 Number of functions evaluations: 13

    The losses at step 10013 are:

    • train loss: 4.37e-07
    • test loss: 1.08e-08

    more precisely:

    [1.03e-08, 4.94e-10, 4.20e-07, 1.98e-09, 9.10e-10, 2.34e-09, 9.91e-10]

    Even though I used a lot of training points and a very deep NN, to obtain a solution that fits the analytic one seems pretty much out of reach for me, so far:

    dam

    I tried to add a laplacian with a little bit of viscosity in the momentum equation but I could’t get to a better result.

    I noticed that applying the hard constraint for the IC of a Riemann problem does not work because the initial discontinuity does not move from the initial point. Essentially, I can’t get the Riemann problem to an evolution if I hard constrain the IC.

    What is wrong in my approach? What should be tweaked?

    Thank you, Riccardo

    opened by Ryszard2 46
  • how to implement different boundary condition on different geometry part

    how to implement different boundary condition on different geometry part

    kindly help me in implementing the different boundary condition in the different geometry of the problem,

    Like. in unit square two sides have Dirichlet BC and Two sides have Neumann BC.

    opened by sumantkrsoni 45
  • General Discussion for train loss,  test Loss value and result accuracy

    General Discussion for train loss, test Loss value and result accuracy

    Hello @lululxvi ,

    • How can we get the desired accuracy of the output result? ( suppose for error value== 1e-8).

    • can we correlate Train, Test value to the accuracy of the result?

    • Also, how can we prevent a problem for overfitting and underfitting

    opened by sumantkrsoni 39
  • BC Over Geometry Part

    BC Over Geometry Part

    hii @lululxvi , I am solving Navier stoke equation which three systems of PDE equation:

    while compiling it shows an error for concatenation:

    ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 0, the array at index 0 has size 2000 and the array at index 1 has size 1000

    Also, in the Geometry part, I have taken a circle with radius 0.2 centered at the center of rectangle:

    Whose code is:

        geom1 = dde.geometry.Rectangle([0,0], [ 12, 5 ])
        geom2 = dde.geometry.Disk( [4.0 , 2.5], 0.2 )
        
        geom = geom1-geom2
    

    I want to put the values of variables over the circle boundary part : u = 0; (component = 0) v = 0; ( component =1)

    I have coded it as:

    bc_circle_u = dde.DirichletBC(geom2, lambda x: np.zeros( (len(x) ,1 ) ), lambda _, on_boundary: on_boundary, component =0)
    
    bc_circle_v = dde.DirichletBC(geom2, lambda x: np.zeros( (len(x) ,1 ) ), lambda _, on_boundary: on_boundary, component =1)
    
    • kindly suggest me whether my code for circle part is right or any modification required:
    opened by sumantkrsoni 38
  • Data sampling strategy and model save/restore

    Data sampling strategy and model save/restore

    Dear Lu, I have another puzzle when running the code. Let's say we sample 50 points along the boundary, where bcs = [bc_rectX,bc_rectY, bc_circleX, bc_circleY] data = dde.data.PDE(geom, pde, bcs, num_domain=300, num_boundary=50, num_test=20) When the code is running, it always issue a warning: Warning: 50 points required, but 100 points sampled. Uniform random is not guaranteed. Warning: CSGDifference.uniform_points not implemented. Use random_points instead.

    If I set the bounary points=100, it will sample 200 points randomly rather than uniformly. What's the reason causing this problem?

    opened by jhssyb 35
  • If I would like to specify the intial boundary  value condition, how to define boudary condition?

    If I would like to specify the intial boundary value condition, how to define boudary condition?

    Hello @lululxvi I want to solve the heat transfer equation with Dirclet boundary codition , the queation is :
    du/dt - ddu/ddx - ddu/ddy-3sinx siny exp(t)=0 with the realistic solution is u=sinx*siny *exp(t), which can not be used in the process, we assume we can not get the solution. the space geom is rectange, [0,1]X[0,1], the time is [0,1]. Thank you very much! My code as follow: `from future import absolute_import from future import division from future import print_function

    import numpy as np

    import deepxde as dde from deepxde.backend import tf

    def main(): #定义pde的形式,默认右端项为零 def pde(x, y): dy_x = tf.gradients(y, x)[0] dy_x, dy_y,dy_t = dy_x[:, 0:1], dy_x[:, 1:2], dy_x[:, 2:] dy_xx = tf.gradients(dy_x, x)[0][:, 0:1] dy_yy = tf.gradients(dy_y, x)[0][:, 1:2] return ( dy_t - dy_xx -dy_yy -3*np.sin(x[:, 0:1])*np.sin(x[:, 1:2])*np.exp(x[:, 2:]) )

    #首先给出初始条件 def func_initial(x): return np.sin(x[:, 0:1])*np.sin(x[:, 1:2])

    #其次定义边界条件 def boundary_Lx0(x, on_boundary): return on_boundary and np.isclose(x[0], 0) def boundary_Rx1(x, on_boundary): return on_boundary and np.isclose(x[0], np.sin(1)*np.sin(x[:, 1:2])*np.exp(x[:, 2:])) def boundary_Ly0(x, on_boundary): return on_boundary and np.isclose(x[0], 0) def boundary_Ry1(x, on_boundary): return on_boundary and np.isclose(x[0], np.sin(x[:, 0:1])*np.sin(1)*np.exp(x[:, 2:]))

    #定义pde右边,一般都是零 def func(x): return np.ones((len(x), 1 ))

    #确定区域的形状:矩形区域,时间为[0,1]
    geom = dde.geometry.Rectangle([0,0],[1,1]) timedomain = dde.geometry.TimeDomain(0, 1) geomtime = dde.geometry.GeometryXTime(geom, timedomain)

    #给出区域的边界条件
    bc_Lx0= dde.DirichletBC(geom, func, boundary_Lx0)
    bc_Rx1= dde.DirichletBC(geom, func, boundary_Rx1) bc_Ly0= dde.DirichletBC(geom, func, boundary_Ly0)
    bc_Ry1= dde.DirichletBC(geom, func, boundary_Ry1)

    #给出区域的初始条件 IBC= dde.IC(geomtime, func_initial, lambda _, on_initial: on_initial) DBC=[bc_Lx0, bc_Rx1, bc_Ly0, bc_Ry1]

    data = dde.data.TimePDE(
        geomtime,
        pde,
        [DBC, IBC],
        num_domain=400,
        num_boundary=10,
        num_initial=1,
        num_test=10000,
    )
    
    layer_size = [3] + [32] * 3 + [1]
    activation = "tanh"
    initializer = "Glorot uniform"
    net = dde.maps.FNN(layer_size, activation, initializer)
    
    model = dde.Model(data, net)
    
    model.compile("adam", lr=0.001, metrics=["l2 relative error"])
    losshistory, train_state = model.train(epochs=10000)
    
    dde.saveplot(losshistory, train_state, issave=True, isplot=True)
    

    if name == "main": main()`

    When I make it run, some error happened as : File "E:\DNN_matlab\myrebp\solve_PDE_0811\DeepXDE\deepxde-master\examples\my_example_0819\new_heat_pde_1.py", line 81, in main()

    File "E:\DNN_matlab\myrebp\solve_PDE_0811\DeepXDE\deepxde-master\examples\my_example_0819\new_heat_pde_1.py", line 57, in main data = dde.data.TimePDE(

    File "D:\ProgramData\envs\tensorflow\lib\site-packages\deepxde\data\pde.py", line 166, in init super(TimePDE, self).init(

    File "D:\ProgramData\envs\tensorflow\lib\site-packages\deepxde\data\pde.py", line 44, in init self.train_next_batch()

    File "D:\ProgramData\envs\tensorflow\lib\site-packages\deepxde\utils.py", line 24, in wrapper return func(self, *args, **kwargs)

    File "D:\ProgramData\envs\tensorflow\lib\site-packages\deepxde\data\pde.py", line 90, in train_next_batch self.train_x = np.vstack((self.bc_points(), self.train_x))

    File "D:\ProgramData\envs\tensorflow\lib\site-packages\deepxde\data\pde.py", line 135, in bc_points x_bcs = [bc.collocation_points(self.train_x) for bc in self.bcs]

    File "D:\ProgramData\envs\tensorflow\lib\site-packages\deepxde\data\pde.py", line 135, in x_bcs = [bc.collocation_points(self.train_x) for bc in self.bcs]

    AttributeError: 'list' object has no attribute 'collocation_points'

    opened by zxw4688 33
  • 1D Terzaghi equation with NBC and RBC

    1D Terzaghi equation with NBC and RBC

    Hi Lu, Thank you very much for sharing this amazing tool. I am trying to use this to solve the Terzaghi equation. du/dt = Cv*(d2u/dx2), Two BCs are : u(0,t)=0,u'(H,t)=0 IC : u(x,0)=1 at all the points.

    I want to ask you if my following code is written correctly?

    Cv=4.86e-02 H=10

    def pde(x, u):
        du_x = tf.gradients(u, x)[0]
        du_x, du_t = du_x[:, 0:1], du_x[:, 1:2]
        du_xx = tf.gradients(du_x, x)[0][:, 0:1]
        return du_t - Cv * du_xx
    
    geom = dde.geometry.Interval(0, H)
    timedomain = dde.geometry.TimeDomain(0, 1)
    geomtime = dde.geometry.GeometryXTime(geom, timedomain)
    
    def boundary_l(x, on_boundary):
        return on_boundary and np.isclose(x[0], 0)
    def boundary_r(x, on_boundary):
        return on_boundary and np.isclose(x[0], H)
    
    bc1 = dde.DirichletBC(
        geomtime, lambda x: np.zeros((len(x), 1)), lambda _, on_boundary: boundary_l
    )
    bc2 = dde.NeumannBC(
        geomtime, lambda x: np.zeros((len(x), 1)), lambda _, on_boundary: boundary_r
    )
    ic = dde.IC(
        geomtime, lambda x: np.full_like(x[:, 0:1], 1), lambda _, on_initial: on_initial
    )
    
    data = dde.data.TimePDE(
        geomtime, pde, [bc1,bc2,ic], num_domain=2540, num_boundary=80, num_initial=160,num_test=10000
    )
    
    net = dde.maps.FNN([2] + [32] * 3 + [1], "tanh", "Glorot normal")
    model = dde.Model(data, net)
    
    model.compile("adam", lr=1e-3)
    model.train(epochs=50000)
    model.compile("L-BFGS-B")
    losshistory, train_state = model.train()
    dde.saveplot(losshistory, train_state, issave=True, isplot=True)
    

    My final result is strange

    opened by 979736316 31
  • Periodic boundary condition issue

    Periodic boundary condition issue

    I think there may be a bug in the periodic boundary condition. See this test code

    from __future__ import absolute_import
    from __future__ import division
    from __future__ import print_function
    
    import matplotlib.pyplot as plt
    import numpy as np
    import tensorflow as tf
    import sys
    import deepxde as dde
    
    def main():
        def pde(x, y):
            dy_x = tf.gradients(y, x)[0]
            dy_x, dy_y = dy_x[:, 0:1], dy_x[:, 1:]
            dy_xx = tf.gradients(dy_x, x)[0][:, 0:1]
            dy_yy = tf.gradients(dy_y, x)[0][:, 1:]
    
            return -dy_xx-dy_yy-1
    
        def boundary(x, on_boundary):
            return on_boundary
    
        def func_bdy(x):
            return np.zeros([len(x), 1])
    
        def boundary_l(x, on_boundary):
            return on_boundary and np.isclose(x[1], 0)
    
        def boundary_r(x, on_boundary):
            return on_boundary and np.isclose(x[1], 1.)
    
        def boundary_t(x, on_boundary):
            return on_boundary and np.isclose(x[0], 1)
    
        def boundary_b(x, on_boundary):
            return on_boundary and np.isclose(x[0], 0)
    
        geom = dde.geometry.Rectangle([0,0],[1,1])
        bc = dde.DirichletBC(geom, func_bdy, boundary)
    
        bc1 = dde.DirichletBC(geom, func_bdy, boundary_l)
        bc2 = dde.DirichletBC(geom, func_bdy, boundary_r)
        bc3 = dde.PeriodicBC(geom, 0, boundary_t)
        #bc4 = dde.PeriodicBC(geom, func_bdy, boundary_b)
    
        data = dde.data.PDE(
            geom, 1, pde, [bc1, bc2, bc3], num_domain=1200, num_boundary=120, num_test=1500
        )
        metrics_=None
        net = dde.maps.FNN([2] + [50] * 4 + [1], "tanh", "Glorot uniform")
        model = dde.Model(data, net)
    
        model.compile("adam", lr=0.001, metrics=metrics_)
        model.train(epochs=20000)
        model.compile("L-BFGS-B", metrics=metrics_)
        losshistory, train_state = model.train()
        dde.saveplot(losshistory, train_state, issave=True, isplot=True)
    
    if __name__ == "__main__":
        main()
    

    It is easy to work out that the exact solution is a quadratic function in x. But the results are not.

    By looking at a similar issue in https://github.com/lululxvi/deepxde/issues/10, I want to point out the periodic boundary condition is not just u(x, 0)=u(x, 1). In fact, it should be any derivative at both sides are identical. (The formal condition is u(x, y-1)=u(x, y) for any x,y.) There are a few ways to force it. One way has been described in the PINNs paper by Raissi et al.

    It is possible that I have a mistake in my code, since I am new to your package. Let me know your suggestion.

    Sorry for too many issues, your package has been entertaining us a lot. Thanks a lot for a great package.

    Thanks, Qi

    opened by tangqi 30
  • question about data and bc

    question about data and bc

    hi, lu DeepXDE is really nice, and i have 2 questions. when i use DeepXDE, can i use my own data as training data. if i can ,how to import it? Can i use DeepXDE describe bc like this u(0,t)=finite? i am looking forward your response, thank you very much

    opened by xy1015874723 28
  • How to define the initial  value of Wave equation in your package Deepxde?

    How to define the initial value of Wave equation in your package Deepxde?

    Hello @lululxvi , I would like to solve the Wave euqation as : image In my code, the initial value of the Wave equation is defined as
    image My code is : ` from future import absolute_import from future import division from future import print_function

    import numpy as np

    import deepxde as dde from deepxde.backend import tf

    def main(): beta=4.0 c=(beta**2)/8 #定义pde的形式,默认右端项为零 def pde(x, y): dy_x = tf.gradients(y, x)[0] dy_x, dy_y,dy_t = dy_x[:, 0:1], dy_x[:, 1:2], dy_x[:, 2:3] dy_xx = tf.gradients(dy_x, x)[0][:, 0:1] dy_yy = tf.gradients(dy_y, x)[0][:, 1:2] dy_tt = tf.gradients(dy_t, x)[0][:, 2:3] return dy_tt - c*(dy_xx+ dy_yy)

    def func(x):
        return np.sin(x[:, 0:1]+x[:, 1:2])*np.cos(x[:, 0:1]+x[:, 1:2])*np.sin(beta*x[:,2:3])
    def dt_func(x):
        return beta*np.sin(x[:, 0:1]+x[:, 1:2])*np.cos(x[:, 0:1]+x[:, 1:2])*np.cos(beta*x[:,2:3])
    

    #确定区域的形状:矩形区域,时间为[0,1] geom = dde.geometry.Rectangle([0,0],[1,1]) timedomain = dde.geometry.TimeDomain(0, 1) geomtime = dde.geometry.GeometryXTime(geom, timedomain)

    #给出区域的初始条件 IBC0 = dde.IC(geomtime, func, lambda _, on_initial: on_initial) dt_IBC0 = dde.IC(geomtime, dt_func, lambda _, on_initial: on_initial) DBC = dde.DirichletBC(geomtime, func, lambda _, on_boundary: on_boundary)

    data = dde.data.TimePDE(
        geomtime,
        pde,
        [DBC, IBC0, dt_IBC0],
        num_domain=1000,
        num_boundary=10,
        num_initial=30,
        solution=func,
        num_test=1000,
    )
    
    layer_size = [3] + [32] * 3 + [1]
    activation = "tanh"
    initializer = "Glorot uniform"
    net = dde.maps.FNN(layer_size, activation, initializer)
    
    model = dde.Model(data, net)
    
    model.compile("adam", lr=0.0001, metrics=["l2 relative error"])
    losshistory, train_state = model.train(epochs=50000)
    
    dde.saveplot(losshistory, train_state, issave=True, isplot=True)
    
    X = geomtime.random_points(100000)
    y_true = func(X)
    y_pred = model.predict(X)
    print("L2 relative error:", dde.metrics.l2_relative_error(y_true, y_pred))
    np.savetxt("test0921.dat", np.hstack((X, y_true, y_pred)))
    

    if name == "main": main()`

    opened by zxw4688 28
  • Add DistributedDataParallel training with paddle

    Add DistributedDataParallel training with paddle

    Add DistributedDataParallel training for 5 model with paddle:Poisson_Dirichlet_1ddiffusion_reaction_ratePoisson_Dirichlet_1d_exactBCPoisson_multiscale_1dwave_1d

    Main logic is depicted below deepxde多卡支持示意图

    opened by HydrogenSulfate 3
  • PINN inverse to predict a constant in a kernel for an IDE

    PINN inverse to predict a constant in a kernel for an IDE

    Discussed in https://github.com/lululxvi/deepxde/discussions/1064

    Originally posted by m-ayyad December 3, 2022 I am trying to do an inverse PINN to predict a parameter in the integral term in an IDE.

     k = dde.Variable(1.0)
     c = dde.Variable(1.0)
     A = dde.Variable(1.0)
    
    def IDE_system(t, theta, int_mat):
       rhs = To_true / I_true * tf.math.sin(omega_true*t)
    
       dtheta_t = dde.grad.jacobian(theta, t)
       dtheta_tt = dde.grad.hessian(theta, t)
    
       lhs1 = c * tf.matmul(int_mat, dtheta_t)
       lhs2 = dtheta_tt + k * theta
    
       lhs = lhs1 + lhs2[: tf.size(lhs1)]
    
       return lhs - rhs[: tf.size(lhs1)]
    
     def kernel(t, tao):
        return np.exp(-A * (t - tao))
    

    It shows the following error

    NotImplementedError: Cannot convert a symbolic tf.Tensor (Exp:0) to a numpy array. This error may indicate that you're trying to pass a Tensor to a NumPy call, which is not supported.

    I tried to change the return of the kernel to return tf.math.exp(-A * (t - tao)) but the same error is issued

    I believe the problem is in the gauss-quadrature code in the IDE soyrce code. I tried to change the it to use tensorflow instead of numpy functions but I didn't find a gauss-quadrature function in tensorflow. Did anyone face a similar problem?

    Thanks, Mahmoud

    opened by m-ayyad 2
  • ODE Inverse problem : Wrong inferred value of parameter , though small loss

    ODE Inverse problem : Wrong inferred value of parameter , though small loss

    Hi @lululxvi,

    Thank you for your wonderful framework and documentation!

    And I have used deepxde to make some simple inverse problems in odes which have 6~8 eqs.

    But I meet some problems in doing a more complex invers ode model. The majority of my step are followed your SBINN paper. First I did Structural Identifiability of all parameters. image define my parameters image I did little scaling in ode image Set my model image And I also did some scaling in output_transform to ensure the output of NN in the proper magnitude image

    In training NN ,I set the loss_weight to make sure each loss items in same magnitude in step 0 image image image

    After training about 80k the loss is pretty small ,but the inference was wrong image image The right value should be 0.7 , 0.16, 0.63 , 5.5 respectively

    However the PINN can work well when I estimate 1 or 2 parameters

    I really hope you can give me suggestion about my problems. Much appreciate!!!!!

    opened by ZSTanone 2
  • A question about the results of inverse problem(PINN)

    A question about the results of inverse problem(PINN)

    Dear @lululxvi and team, I recently used the pinn library to solve the odes parameter prediction problem. In order to verify the applicability of my equation, I assumed unknown parameters, and then used the numerical solution results as the input of pinn, as the training set and test set, and then used pinn for prediction, and got perfect results. The parameter all-round prediction pair, and the pinn prediction results were also consistent with the input. The prediction results are inversely inserted into the odes numerical
    solution results are also consistent, these three curves coincide perfectly. And that proves the applicability of my equation. Now I transfer pinn's input to the experimental results, a prediction using pinn, pinn prediction results can also be very good and the input data for training and test loss are small, but the predicted parameters into the odes, found the result is not with the input and pinn prediction results on, sometimes even can't in good trend. As for this problem, I don't know whether the result of my experiment does not fit my equation well or what is the problem. Do you have any good suggestions on the procedure of this problem? I wanted to start with the loss function, but I don't understand it yet. Do you have any good
    suggestions?

    The first two figures are the training results based on numerical solution data, and the last two figures are the training results based on experimental data.

    图片2 图片1 图片3 图片4

    opened by GitHubSPlus 3
Releases(v1.7.2)
  • v1.7.2(Dec 4, 2022)

    Areas of improvement

    • Add dde.icbc.PointSetOperatorBC
    • dde.callbacks.OperatorPredictor can be used during training
    • Backend PyTorch: dde.icbc.PointSetBC supports multi-component outputs
    • Bug fix
    Source code(tar.gz)
    Source code(zip)
  • v1.7.1(Nov 7, 2022)

    Areas of improvement

    • dde.data.TripleCartesianProd and dde.data.QuadrupleCartesianProd support mini-batch for both branch and trunk nets
    • Backend TensorFlow 1.x: L-BFGS dumps trainable variables and test loss
    Source code(tar.gz)
    Source code(zip)
  • v1.7.0(Sep 28, 2022)

    Areas of improvement

    • dde.icbc.PointSetBC supports mini-batch
    • Bug fix

    New APIs

    • Backend paddle: Support dde.nn.DeepONet and dde.nn.DeepONetCartesianProd

    API changes

    • Change dde.callback.PDEResidualResampler to dde.callback.PDEPointResampler
    Source code(tar.gz)
    Source code(zip)
  • v1.6.2(Aug 26, 2022)

    Areas of improvement

    • Set Hammersley as the default point sampling for PINN
    • Improve point sampling of dde.geometry.GeometryXTime.random_points
    • dde.callback.ModelCheckpoint supports monitoring test loss
    • PyTorch backend: dde.nn.PODMIONet and dde.nn.MIONetCartesianProd support multiple merge operations
    Source code(tar.gz)
    Source code(zip)
  • v1.6.1(Jul 26, 2022)

    Areas of improvement

    • Backend TensorFlow 1.x dde.nn.DeepONet supports customized branch
    • Fix Triangle.on_boundary for float32
    • Bug fix: a few issues of float64
    • Many documentation improvements

    New APIs

    • Backend PyTorch adds dde.nn.PODMIONet
    • Backend PyTorch adds dde.nn.MIONetCartesianProd
    Source code(tar.gz)
    Source code(zip)
  • v1.6.0(Jun 26, 2022)

    Backend JAX supports PDE inverse problems.🎉🎉🎉

    Areas of improvement

    • Backend PyTorch supports l2 regularization
    • Improve XLA jit

    New APIs

    • Add dde.data.PDEOperatorCartesianProd
    • Backend TensorFlow supports dde.nn.PFNN

    API changes

    • Model.train: epochs is replaced by iterations
    • Merge PIDeepONet into DeepONet
    Source code(tar.gz)
    Source code(zip)
  • v1.5.1(Jun 11, 2022)

  • v1.5.0(Jun 4, 2022)

    Areas of improvement

    • Support new loss "mean l2 relative error"
    • Backend PyTorch supports dde.nn.DeepONetCartesianProd and dde.nn.PODDeepONet
    • Backend PyTorch supports "step" LR decay
    • dde.callbacks.OperatorPredictor supports backends tensorflow.compat.v1, tensorflow, pytorch, paddle
    • Fix dde.config.set_random_seed

    New APIs

    • Add dde.config.enable_xla_jit and dde.config.disable_xla_jit

    API changes

    • Change DDEBACKEND to DDE_BACKEND
    Source code(tar.gz)
    Source code(zip)
  • v1.4.0(May 20, 2022)

    DeepXDE supports a new backend PaddlePaddle.🎉🎉🎉

    Areas of improvement

    • Backend PyTorch supports dde.nn.PFNN
    • Backend TensorFlow 1.x enables XLA for GPU
    Source code(tar.gz)
    Source code(zip)
  • v1.3.1(May 15, 2022)

  • v1.3.0(May 13, 2022)

    Backend JAX supports ODE forward problems.🎉🎉🎉

    Areas of improvement

    • Backend TensorFlow supports model.save and model.restore.
    • Backend TensorFlow uses @tf.function(jit_compile=True) for faster speed.
    Source code(tar.gz)
    Source code(zip)
  • v1.2.0(May 7, 2022)

    DeepXDE supports physics-informed DeepONet.🎉🎉🎉

    Areas of improvement

    • Fix the issue when setting random seed via dde.set_random_seed()

    New APIs

    • Support physics-informed DeepONet
      • Add function spaces: dde.data.PowerSeries, dde.data.Chebyshev, dde.data.GRF, dde.data.GRF_KL, dde.data.GRF2D
      • Add dde.data.PDEOperator
      • Add dde.nn.PIDeepONet
    Source code(tar.gz)
    Source code(zip)
  • v1.1.4(Apr 25, 2022)

    Areas of improvement

    • Fix is_on_line_segment() such as Polygon.boundary_normal() works for float32
    • Refactor backend JAX: utilize vmap, and add auxiliary arguments to data.losses

    New APIs

    • Add NN.num_trainable_parameters()
    Source code(tar.gz)
    Source code(zip)
  • v1.1.3(Mar 16, 2022)

    API changes

    • dde.data.MfDataSet adds a new argument standardize=False, which changes the default behavior of MfDataSet. In the previous version, "standardize" is used by default.
    Source code(tar.gz)
    Source code(zip)
  • v1.1.2(Mar 16, 2022)

    Areas of improvement

    • Backend JAX supports Jacobian
    • Backend JAX uses a random random seed, and supports user-defined random seed
    • MFNN test loss returns 0 instead of nan
    • Bug fix: CSG for float32

    API changes

    • Move saving and plotting functions to utils.external. Delete deepxde/postprocessing.py
    Source code(tar.gz)
    Source code(zip)
  • v1.1.1(Mar 4, 2022)

    Areas of improvement

    • JAX backend supports different optimizers
    • JAX backend: improve FNN to fully support function approximation
    • Improve code format, and code cleaning
    • Bug fix: float64
    • Documentation and examples improvements
    Source code(tar.gz)
    Source code(zip)
  • v1.1.0(Feb 23, 2022)

    DeepXDE supports JAX backend for function approximation. 🎉🎉🎉

    Areas of improvement

    • Bug fix: float64 in PyTorch
    • Documentation and examples improvements

    New APIs

    • Add PODDeepONet
    • Support MIONet: Quadruple, QuadrupleCartesianProd, MIONet, MIONetCartesianProd

    API changes

    • Rename dde.icbcs to dde.icbc
    Source code(tar.gz)
    Source code(zip)
  • v1.0.0(Feb 1, 2022)

    DeepXDE was developed starting from the summer of 2018, self-hosted in Subversion at Brown University, originally under the name SciCoNet (Scientific Computing Neural Networks). On Feb 7, 2019, SciCoNet was moved from Subversion to GitHub, renamed to DeepXDE. The first version v0.1.0 was then released on Jun 12, 2019. After the development of more than three years and a half, DeepXDE with backend TensorFlow 1.x becomes stable, and thus we now release the first stable version v1.0.0! 🎉🎉🎉

    Thank you all for taking the time to contribute! A non-exhaustive but growing list needs to mention: @lululxvi @smao-astro @ZongrenZou @Saransh-cpp @anranjiao @pescap @Handi-Zhang @Anilith etc.

    DeepXDE already has partial support of backend TensorFlow 2.x (from v0.13.0, Jul 21, 2021) and PyTorch (from v0.13.1, Jul 28, 2021). The multiple backend (also JAX) support will be enhanced in DeepXDE v1.x, and more advanced features (e.g., PINN-DeepONet) will be developed.


    Here are the new improvements, compared to the previous version.

    Areas of improvement

    • Stop training if loss becomes nan (#491)
    • EarlyStopping callback can monitor testing loss (#501)
    • Documentation improvements

    New APIs

    • Add set_random_seed to set the global random seed (#495)
    • Add function dat_to_csv to convert dat files to CSV format (#499)
    Source code(tar.gz)
    Source code(zip)
  • v0.14.1(Jan 5, 2022)

    Change license from Apache-2.0 to LGPL-2.1

    Areas of improvement

    • callback MovieDumper supports backend TensorFlow and PyTorch

    New APIs

    • Add PDE.replace_with_anchors()
    Source code(tar.gz)
    Source code(zip)
  • v0.14.0(Dec 5, 2021)

    We stop the support of Python 3.6 from this release.

    Areas of improvement

    • Model.save() and Model.restore() supports backend PyTorch
    • Model.predict() supports PDE auxiliary variables for backend TensorFlow 1.x and TensorFlow 2.x
    • Bug fix on some double/float issues
    • Documentation improvements
    Source code(tar.gz)
    Source code(zip)
  • v0.13.6(Oct 6, 2021)

  • v0.13.5(Sep 5, 2021)

    Areas of improvement

    • TensorFlow 2.x and PyTorch support loss_weights
    • Improve L-BFGS for TensorFLow 2.x and PyTorch
    • Geometry.random_boundary_points() doesn't sample corner points

    New APIs

    • Add dde.optimizers.set_LBFGS_options()
    Source code(tar.gz)
    Source code(zip)
  • v0.13.4(Aug 20, 2021)

    Areas of improvement

    • Backend TensorFlow 2.x supports L-BFGS via TFP
    • Backend PyTorch supports L-BFGS
    • Backend PyTorch uses GPU by default, if available
    • Improve BC/IC performance for backend PyTorch

    New APIs

    • Add dde.Variable for inverse problems
    Source code(tar.gz)
    Source code(zip)
  • v0.13.3(Aug 9, 2021)

    • Backend PyTorch supports PDE inverse problems

    Areas of improvement

    • Refactor some parts of Model
    • Bug fix for backend TensorFlow 2.x and PyTorch

    API changes

    • Rename dde.maps to dde.nn to be more explicit
    Source code(tar.gz)
    Source code(zip)
  • v0.13.2(Aug 5, 2021)

    • Backend PyTorch supports PDE forward problems

    API changes

    • Refactor uncertainty via MC dropout as the callback DropoutUncertainty; remove "uncertainty" argument from Model.train().
    Source code(tar.gz)
    Source code(zip)
  • v0.13.1(Jul 28, 2021)

    DeepXDE supports PyTorch backend for function approximation.

    Areas of improvement

    • Backend TensorFlow supports auxiliary variables

    New APIs

    • Add dde.config.set_default_float() and dde.config.default_float()
    Source code(tar.gz)
    Source code(zip)
  • v0.13.0(Jul 22, 2021)

    DeepXDE now supports two backends: TensorFlow 1.x (tensorflow.compat.v1 in TensorFlow 2.x) and TensorFlow 2.x. For how to select one, see Working with different backends.

    Areas of improvement

    • Many modules are refactored to better support multiple backends.
    • Support skopt>=0.9
    • Documentation improvements

    API changes

    • Rename dde.data.Func to dde.data.Function

    New APIs

    • Add Hypercube.random_boundary_points()
    Source code(tar.gz)
    Source code(zip)
  • v0.12.0(Jul 2, 2021)

    This release is mainly about DeepONet.

    API changes

    • Rename OpNN to DeepONet
    • Rename OpDataSet to Triple

    New APIs

    • Add dde.__version__
    • Add data.TripleCartesianProd, maps.DeepONetCartesianProd, and maps.FourierDeepONetCartesianProd
    • Add new metric: mean_l2_relative_error

    Areas of improvement

    • Bug fix: change 'sobol' to 'Sobol'
    Source code(tar.gz)
    Source code(zip)
  • v0.11.2(Jun 16, 2021)

    Areas of improvement

    • Add Multi-scale Fourier Feature Neural Networks: MsFFN and STMsFFN
    • PDE supports more sampling methods: LHS, Halton, Hammersley
    • DeepONet supports input_transform and output_transform
    • PointSet supports default value
    • Hypercube.boundary_normal() returns averaged normal for vertices
    • Speedup Polygon.random_points()
    Source code(tar.gz)
    Source code(zip)
  • v0.11.1(May 20, 2021)

    Areas of improvement

    • FNN supports arguments use_bias and kernel_constraint, and layer normalization
    • Change L-BFGS option gtol from 1e-5 to 1e-8
    • Improve saveplot

    New APIs

    • Add a new Data Constraint
    • Add metric mean_squared_error
    Source code(tar.gz)
    Source code(zip)
Owner
Lu Lu
Assistant Professor of Chemical and Biomolecular Engineering, University of Pennsylvania
Lu Lu
A framework for analyzing computer vision models with simulated data

3DB: A framework for analyzing computer vision models with simulated data Paper Quickstart guide Blog post Installation Follow instructions on: https:

3DB 112 Jan 01, 2023
PantheonRL is a package for training and testing multi-agent reinforcement learning environments.

PantheonRL is a package for training and testing multi-agent reinforcement learning environments. PantheonRL supports cross-play, fine-tuning, ad-hoc coordination, and more.

Stanford Intelligent and Interactive Autonomous Systems Group 57 Dec 28, 2022
This repository is a series of notebooks that show solutions for the projects at Dataquest.io.

Dataquest Project Solutions This repository is a series of notebooks that show solutions for the projects at Dataquest.io. Of course, there are always

Dataquest 1.1k Dec 30, 2022
Recursive Bayesian Networks

Recursive Bayesian Networks This repository contains the code to reproduce the results from the NeurIPS 2021 paper Lieck R, Rohrmeier M (2021) Recursi

Robert Lieck 11 Oct 18, 2022
The lightweight PyTorch wrapper for high-performance AI research. Scale your models, not the boilerplate.

The lightweight PyTorch wrapper for high-performance AI research. Scale your models, not the boilerplate. Website • Key Features • How To Use • Docs •

Pytorch Lightning 21.1k Jan 01, 2023
Get a Grip! - A robotic system for remote clinical environments.

Get a Grip! Within clinical environments, sterilization is an essential procedure for disinfecting surgical and medical instruments. For our engineeri

Jay Sharma 1 Jan 05, 2022
Code for "MetaMorph: Learning Universal Controllers with Transformers", Gupta et al, ICLR 2022

MetaMorph: Learning Universal Controllers with Transformers This is the code for the paper MetaMorph: Learning Universal Controllers with Transformers

Agrim Gupta 50 Jan 03, 2023
Demo notebooks for Qiskit application modules demo sessions (Oct 8 & 15):

qiskit-application-modules-demo-sessions This repo hosts demo notebooks for the Qiskit application modules demo sessions hosted on Qiskit YouTube. Par

Qiskit Community 46 Nov 24, 2022
Face detection using deep learning.

Face Detection Docker Solution Using Faster R-CNN Dockerface is a deep learning face detector. It deploys a trained Faster R-CNN network on Caffe thro

Nataniel Ruiz 181 Dec 19, 2022
Efficient Online Bayesian Inference for Neural Bandits

Efficient Online Bayesian Inference for Neural Bandits By Gerardo Durán-Martín, Aleyna Kara, and Kevin Murphy AISTATS 2022.

Probabilistic machine learning 49 Dec 27, 2022
Awesome Transformers in Medical Imaging

This repo supplements our Survey on Transformers in Medical Imaging Fahad Shamshad, Salman Khan, Syed Waqas Zamir, Muhammad Haris Khan, Munawar Hayat,

Fahad Shamshad 666 Jan 06, 2023
SplineConv implementation for Paddle.

SplineConv implementation for Paddle This module implements the SplineConv operators from Matthias Fey, Jan Eric Lenssen, Frank Weichert, Heinrich Mül

北海若 3 Dec 29, 2021
The PyTorch implementation of paper REST: Debiased Social Recommendation via Reconstructing Exposure Strategies

REST The PyTorch implementation of paper REST: Debiased Social Recommendation via Reconstructing Exposure Strategies. Usage Download dataset Download

DMIRLAB 2 Mar 13, 2022
Interactive Image Segmentation via Backpropagating Refinement Scheme

Won-Dong Jang and Chang-Su Kim, Interactive Image Segmentation via Backpropagating Refinement Scheme, CVPR 2019

Won-Dong Jang 85 Sep 15, 2022
PyTorch Implementation of Daft-Exprt: Robust Prosody Transfer Across Speakers for Expressive Speech Synthesis

Daft-Exprt - PyTorch Implementation PyTorch Implementation of Daft-Exprt: Robust Prosody Transfer Across Speakers for Expressive Speech Synthesis The

Keon Lee 47 Dec 18, 2022
Official PyTorch Implementation of "Self-supervised Auxiliary Learning with Meta-paths for Heterogeneous Graphs". NeurIPS 2020.

Self-supervised Auxiliary Learning with Meta-paths for Heterogeneous Graphs This repository is the implementation of SELAR. Dasol Hwang* , Jinyoung Pa

MLV Lab (Machine Learning and Vision Lab at Korea University) 48 Nov 09, 2022
Taming Transformers for High-Resolution Image Synthesis

Taming Transformers for High-Resolution Image Synthesis CVPR 2021 (Oral) Taming Transformers for High-Resolution Image Synthesis Patrick Esser*, Robin

CompVis Heidelberg 3.5k Jan 03, 2023
“Robust Lightweight Facial Expression Recognition Network with Label Distribution Training”, AAAI 2021.

EfficientFace Zengqun Zhao, Qingshan Liu, Feng Zhou. "Robust Lightweight Facial Expression Recognition Network with Label Distribution Training". AAAI

Zengqun Zhao 119 Jan 08, 2023
ICLR 2021, Fair Mixup: Fairness via Interpolation

Fair Mixup: Fairness via Interpolation Training classifiers under fairness constraints such as group fairness, regularizes the disparities of predicti

Ching-Yao Chuang 49 Nov 22, 2022
Local trajectory planner based on a multilayer graph framework for autonomous race vehicles.

Graph-Based Local Trajectory Planner The graph-based local trajectory planner is python-based and comes with open interfaces as well as debug, visuali

TUM - Institute of Automotive Technology 160 Jan 04, 2023