Skip to content

Commit

Permalink
Improve demo file.
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelburbulla committed May 11, 2023
1 parent 8a90a3f commit 9760c7a
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions docs/demos/operator/pideeponet_poisson1d.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ for the one-dimensional Poisson problem

with zero Dirichlet boundary conditions :math:`u(0) = u(1) = 0`.

The source term :math:`f` is supposed to be an arbitrary continuous function,
we choose polynomials of degree three.
The source term :math:`f` is supposed to be an arbitrary continuous function.


Implementation
Expand Down Expand Up @@ -51,6 +50,8 @@ First, we define the PDE with boundary conditions and the domain:
Next, we specify the function space for :math:`f` and the corresponding evaluation points.
For this example, we use the ``dde.data.PowerSeries`` to get the function space
of polynomials of degree three.
Together with the PDE, the function space is used to define a
PDEOperator ``dde.data.PDEOperatorCartesianProd`` that incorporates the PDE into
the loss function.
Expand All @@ -72,8 +73,8 @@ the loss function.
The DeepONet can be defined using ``dde.nn.DeepONetCartesianProd``.
The branch net is chosen as a fully connected neural network of size ``[m, 32, p]`` where ``p=32``,
and the the trunk net is a fully connected neural network of size ``[dim_x, 32, p]``.
The branch net is chosen as a fully connected neural network of size ``[m, 32, p]`` where ``p=32``
and the trunk net is a fully connected neural network of size ``[dim_x, 32, p]``.

.. code-block:: python
Expand All @@ -87,7 +88,7 @@ and the the trunk net is a fully connected neural network of size ``[dim_x, 32,
)
We define a ``Model`` and train it with L-BFGS (pytorch) or Adam:
We define the ``Model`` and train it with either L-BFGS (pytorch) or Adam:

.. code-block:: python
Expand All @@ -101,7 +102,17 @@ We define a ``Model`` and train it with L-BFGS (pytorch) or Adam:
model.train(iterations=10000)
Finally, the trained model can be used to predict the solution of the Poisson
equation for any admissible source term :math:`f`.
equation. We sample the solution for three random representations of :math:`f`.

.. code-block:: python
n = 3
features = space.random(n)
fx = space.eval_batch(features, evaluation_points)
x = geom.uniform_points(100, boundary=True)
y = model.predict((fx, x))
![](pideeponet_poisson1d.png)

Expand Down

0 comments on commit 9760c7a

Please sign in to comment.