From 9760c7af5a9500b4da60fec09cd1f56c1613afd7 Mon Sep 17 00:00:00 2001 From: Samuel Burbulla Date: Thu, 11 May 2023 17:05:09 +0200 Subject: [PATCH] Improve demo file. --- docs/demos/operator/pideeponet_poisson1d.rst | 23 +++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/docs/demos/operator/pideeponet_poisson1d.rst b/docs/demos/operator/pideeponet_poisson1d.rst index 23b76c9f0..60ba2ce80 100644 --- a/docs/demos/operator/pideeponet_poisson1d.rst +++ b/docs/demos/operator/pideeponet_poisson1d.rst @@ -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 @@ -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. @@ -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 @@ -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 @@ -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)