Skip to content

Commit

Permalink
update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
enigne committed Jun 6, 2024
1 parent 3ad276a commit 219dd68
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 30 deletions.
8 changes: 8 additions & 0 deletions docs/api/pinnicle.physics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ pinnicle.physics.continuity module
:undoc-members:
:show-inheritance:

pinnicle.physics.dummy module
-----------------------------

.. automodule:: pinnicle.physics.dummy
:members:
:undoc-members:
:show-inheritance:

pinnicle.physics.stressbalance module
-------------------------------------

Expand Down
61 changes: 61 additions & 0 deletions docs/examples/advanced.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
Advanced Features in PINNICLE
=============================

PINNICLE is under active development, and several **advanced**/**experimental** features are listed here in alphabetical order:

Additional Loss Functions
-------------------------

It is possible to add additional loss functions to the total loss. Here is an example:

.. code-block:: python
vel_loss = {}
vel_loss['name'] = "vel MAPE"
vel_loss['function'] = "MAPE"
vel_loss['weight'] = 1.0e-6
hp["additional_loss"] = {"vel":vel_loss}
In this example, we define a `dict` which contains:
- `name`: A user-defined name for the loss function.
- `function`: A function ID from `LOSS_DICT` in `deepxde.losses <https://deepxde.readthedocs.io/en/latest/_modules/deepxde/losses.html#get>`_ or `pinnicle.utils.data_misfit <https://pinnicle.readthedocs.io/en/latest/_modules/pinnicle/utils/data_misfit.html#get>`_. These lists include most commonly used loss functions, such as `"mean"`, `"MAE"`, `"MSE"`, `"MAPE"`, `"zero"`, `"VEL_LOG"`, `"MEAN_SQUARE_LOG"`, etc. Before writing your own loss function, refer to these lists, as these functions are optimized with the backends.
- `weight`: the weight of this loss function.

Finally, add the new `dict` to `hp["additional_loss"]` with the key indicating the variable to which this loss function should be applied. In the above example, we are adding the mean absolute percentage error of the velocity magnitude to the total loss.

Dummy Equations
---------------

PINNICLE provides `Dummy <https://pinnicle.readthedocs.io/en/latest/api/pinnicle.physics.html#module-pinnicle.physics.dummy>`_ physics, which allows you to train the neural network using data only. Here is an example:

.. code-block:: python
dummy = {}
dummy["output"] = ['u', 's', 'C']
hp["equations"] = {"DUMMY": dummy}
In this example, we define a `dict` with a key `output`, where the value is a list of three output variables. Then, we add this `dict` to `hp['equations']` with the key `DUMMY` (all uppercase). Additionally, you need to provide the data for `u`, `s`, and `C` in the `data` section, similar to other examples. The neural network will then be trained solely with the provided data.

By default, the `Dummy` physics already has `x` and `y` as `input`. If there is no need to change this, only the `output` needs to be defined.


Architecture of the Neural Network
----------------------------------

PINNICLE supports both fully connected neural networks and parallel neural networks. To choose one, simply set `hp["is_parallel"]` to `False` or `True`. Currently, PINNICLE only supports parallel networks for each individual output, and all these networks are of the same size.

Another feature of the neural network architecture is that you can set the number of neurons and layers as follows:

.. code-block:: python
hp["num_neurons"] = 20
hp["num_layers"] = 4
This configuration creates a network with 4 layers, each containing 20 neurons. Alternatively, you can define the number of neurons in each layer using a list:

.. code-block:: python
hp["num_neurons"] = [128, 64, 32, 16]
In this case, the number of layers is inferred from the length of the list, creating a network with 4 layers having 128, 64, 32, and 16 neurons respectively.

File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ User guide
.. toctree::
:maxdepth: 1

pinn_examples
pinnicle_examples


API reference
Expand Down
2 changes: 1 addition & 1 deletion docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ In the future, PINNICLE will support the following backends:

- To install and use the package, you should clone the folder to your local machine and put it along with your project scripts::

$ git clone https://github.com/enigne/PINNICLE.git
$ git clone https://github.com/ISSMteam/PINNICLE.git

* Other dependencies

Expand Down
28 changes: 0 additions & 28 deletions docs/pinn_examples.rst

This file was deleted.

23 changes: 23 additions & 0 deletions docs/pinnicle_examples.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Examples
========

Here are some examples of solving ice sheet modeling problems using PINNICLE

Basic
-----

.. toctree::
:maxdepth: 1

examples/ssa
examples/mc
examples/couple

Advanced
--------

.. toctree::
:maxdepth: 2

examples/advanced

0 comments on commit 219dd68

Please sign in to comment.