Skip to content

Commit 78ed2a6

Browse files
authored
Colab tutorials (#367)
* Colab Button & Run added
1 parent 6a4febb commit 78ed2a6

File tree

39 files changed

+526
-52
lines changed

39 files changed

+526
-52
lines changed

docs/source/_rst/tutorials/tutorial1/tutorial.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
Tutorial: Physics Informed Neural Networks on PINA
22
==================================================
33

4+
|Open In Colab|
5+
6+
.. |Open In Colab| image:: https://colab.research.google.com/assets/colab-badge.svg
7+
:target: https://colab.research.google.com/github/mathLab/PINA/blob/master/tutorials/tutorial1/tutorial.ipynb
8+
49
In this tutorial, we will demonstrate a typical use case of **PINA** on
510
a toy problem, following the standard API procedure.
611

@@ -74,6 +79,15 @@ What if our equation is also time-dependent? In this case, our ``class``
7479
will inherit from both ``SpatialProblem`` and ``TimeDependentProblem``:
7580

7681
.. code:: ipython3
82+
83+
## routine needed to run the notebook on Google Colab
84+
try:
85+
import google.colab
86+
IN_COLAB = True
87+
except:
88+
IN_COLAB = False
89+
if IN_COLAB:
90+
!pip install "pina-mathlab"
7791
7892
from pina.problem import SpatialProblem, TimeDependentProblem
7993
from pina.geometry import CartesianDomain

docs/source/_rst/tutorials/tutorial10/tutorial.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
Tutorial: Averaging Neural Operator for solving Kuramoto Sivashinsky equation
22
=============================================================================
33

4+
|Open In Colab|
5+
6+
.. |Open In Colab| image:: https://colab.research.google.com/assets/colab-badge.svg
7+
:target: https://colab.research.google.com/github/mathLab/PINA/blob/master/tutorials/tutorial10/tutorial.ipynb
8+
49
In this tutorial we will build a Neural Operator using the
510
``AveragingNeuralOperator`` model and the ``SupervisedSolver``. At the
611
end of the tutorial you will be able to train a Neural Operator for
@@ -11,6 +16,15 @@ operations.
1116

1217
.. code:: ipython3
1318
19+
## routine needed to run the notebook on Google Colab
20+
try:
21+
import google.colab
22+
IN_COLAB = True
23+
except:
24+
IN_COLAB = False
25+
if IN_COLAB:
26+
!pip install "pina-mathlab"
27+
1428
import torch
1529
import matplotlib.pyplot as plt
1630
from scipy import io

docs/source/_rst/tutorials/tutorial11/tutorial.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
Tutorial: PINA and PyTorch Lightning, training tips and visualizations
22
======================================================================
33

4+
|Open In Colab|
5+
6+
.. |Open In Colab| image:: https://colab.research.google.com/assets/colab-badge.svg
7+
:target: https://colab.research.google.com/github/mathLab/PINA/blob/master/tutorials/tutorial11/tutorial.ipynb
8+
49
In this tutorial, we will delve deeper into the functionality of the
510
``Trainer`` class, which serves as the cornerstone for training **PINA**
611
`Solvers <https://mathlab.github.io/PINA/_rst/_code.html#solvers>`__.
@@ -18,6 +23,15 @@ problem and the ``PINN`` solver.
1823

1924
.. code:: ipython3
2025
26+
## routine needed to run the notebook on Google Colab
27+
try:
28+
import google.colab
29+
IN_COLAB = True
30+
except:
31+
IN_COLAB = False
32+
if IN_COLAB:
33+
!pip install "pina-mathlab"
34+
2135
import torch
2236
2337
from pina import Condition, Trainer

docs/source/_rst/tutorials/tutorial12/tutorial.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
Tutorial: The ``Equation`` Class
22
================================
33

4+
|Open In Colab|
5+
6+
.. |Open In Colab| image:: https://colab.research.google.com/assets/colab-badge.svg
7+
:target: https://colab.research.google.com/github/mathLab/PINA/blob/master/tutorials/tutorial12/tutorial.ipynb
8+
49
In this tutorial, we will show how to use the ``Equation`` Class in
510
PINA. Specifically, we will see how use the Class and its inherited
611
classes to enforce residuals minimization in PINNs.
@@ -30,6 +35,15 @@ class.
3035

3136
.. code:: ipython3
3237
38+
## routine needed to run the notebook on Google Colab
39+
try:
40+
import google.colab
41+
IN_COLAB = True
42+
except:
43+
IN_COLAB = False
44+
if IN_COLAB:
45+
!pip install "pina-mathlab"
46+
3347
#useful imports
3448
from pina.problem import SpatialProblem, TimeDependentProblem
3549
from pina.equation import Equation, FixedValue, FixedGradient, FixedFlux

docs/source/_rst/tutorials/tutorial13/tutorial.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
Tutorial: Multiscale PDE learning with Fourier Feature Network
22
==============================================================
33

4+
|Open In Colab|
5+
6+
.. |Open In Colab| image:: https://colab.research.google.com/assets/colab-badge.svg
7+
:target: https://colab.research.google.com/github/mathLab/PINA/blob/master/tutorials/tutorial13/tutorial.ipynb
8+
49
This tutorial presents how to solve with Physics-Informed Neural
510
Networks (PINNs) a PDE characterized by multiscale behaviour, as
611
presented in `On the eigenvector bias of Fourier feature networks: From
@@ -11,6 +16,15 @@ First of all, some useful imports.
1116

1217
.. code:: ipython3
1318
19+
## routine needed to run the notebook on Google Colab
20+
try:
21+
import google.colab
22+
IN_COLAB = True
23+
except:
24+
IN_COLAB = False
25+
if IN_COLAB:
26+
!pip install "pina-mathlab"
27+
1428
import torch
1529
1630
from pina import Condition, Plotter, Trainer, Plotter

docs/source/_rst/tutorials/tutorial2/tutorial.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
Tutorial: Two dimensional Poisson problem using Extra Features Learning
22
=======================================================================
33

4+
|Open In Colab|
5+
6+
.. |Open In Colab| image:: https://colab.research.google.com/assets/colab-badge.svg
7+
:target: https://colab.research.google.com/github/mathLab/PINA/blob/master/tutorials/tutorial2/tutorial.ipynb
8+
9+
410
This tutorial presents how to solve with Physics-Informed Neural
511
Networks (PINNs) a 2D Poisson problem with Dirichlet boundary
612
conditions. We will train with standard PINN’s training, and with
@@ -13,6 +19,15 @@ First of all, some useful imports.
1319

1420
.. code:: ipython3
1521
22+
## routine needed to run the notebook on Google Colab
23+
try:
24+
import google.colab
25+
IN_COLAB = True
26+
except:
27+
IN_COLAB = False
28+
if IN_COLAB:
29+
!pip install "pina-mathlab"
30+
1631
import torch
1732
from torch.nn import Softplus
1833

docs/source/_rst/tutorials/tutorial3/tutorial.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
Tutorial: Two dimensional Wave problem with hard constraint
22
===========================================================
33

4+
|Open In Colab|
5+
6+
.. |Open In Colab| image:: https://colab.research.google.com/assets/colab-badge.svg
7+
:target: https://colab.research.google.com/github/mathLab/PINA/blob/master/tutorials/tutorial3/tutorial.ipynb
8+
9+
410
In this tutorial we present how to solve the wave equation using hard
511
constraint PINNs. For doing so we will build a costum ``torch`` model
612
and pass it to the ``PINN`` solver.
@@ -9,6 +15,15 @@ First of all, some useful imports.
915

1016
.. code:: ipython3
1117
18+
## routine needed to run the notebook on Google Colab
19+
try:
20+
import google.colab
21+
IN_COLAB = True
22+
except:
23+
IN_COLAB = False
24+
if IN_COLAB:
25+
!pip install "pina-mathlab"
26+
1227
import torch
1328
1429
from pina.problem import SpatialProblem, TimeDependentProblem

docs/source/_rst/tutorials/tutorial4/tutorial.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
Tutorial: Unstructured convolutional autoencoder via continuous convolution
22
===========================================================================
33

4+
|Open In Colab|
5+
6+
.. |Open In Colab| image:: https://colab.research.google.com/assets/colab-badge.svg
7+
:target: https://colab.research.google.com/github/mathLab/PINA/blob/master/tutorials/tutorial4/tutorial.ipynb
8+
49
In this tutorial, we will show how to use the Continuous Convolutional
510
Filter, and how to build common Deep Learning architectures with it. The
611
implementation of the filter follows the original work `A Continuous
@@ -11,6 +16,15 @@ First of all we import the modules needed for the tutorial:
1116

1217
.. code:: ipython3
1318
19+
## routine needed to run the notebook on Google Colab
20+
try:
21+
import google.colab
22+
IN_COLAB = True
23+
except:
24+
IN_COLAB = False
25+
if IN_COLAB:
26+
!pip install "pina-mathlab"
27+
1428
import torch
1529
import matplotlib.pyplot as plt
1630
from pina.problem import AbstractProblem

docs/source/_rst/tutorials/tutorial5/tutorial.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
Tutorial: Two dimensional Darcy flow using the Fourier Neural Operator
22
======================================================================
33

4+
|Open In Colab|
5+
6+
.. |Open In Colab| image:: https://colab.research.google.com/assets/colab-badge.svg
7+
:target: https://colab.research.google.com/github/mathLab/PINA/blob/master/tutorials/tutorial5/tutorial.ipynb
8+
49
In this tutorial we are going to solve the Darcy flow problem in two
510
dimensions, presented in `Fourier Neural Operator for Parametric Partial
611
Differential Equation <https://openreview.net/pdf?id=c8P9NQVtmnO>`__.
@@ -9,6 +14,16 @@ First of all we import the modules needed for the tutorial. Importing
914

1015
.. code:: ipython3
1116
17+
## routine needed to run the notebook on Google Colab
18+
try:
19+
import google.colab
20+
IN_COLAB = True
21+
except:
22+
IN_COLAB = False
23+
if IN_COLAB:
24+
!pip install "pina-mathlab"
25+
!pip install scipy
26+
1227
# !pip install scipy # install scipy
1328
from scipy import io
1429
import torch

docs/source/_rst/tutorials/tutorial6/tutorial.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
Tutorial: Building custom geometries with PINA ``Location`` class
22
=================================================================
33

4+
|Open In Colab|
5+
6+
.. |Open In Colab| image:: https://colab.research.google.com/assets/colab-badge.svg
7+
:target: https://colab.research.google.com/github/mathLab/PINA/blob/master/tutorials/tutorial6/tutorial.ipynb
8+
49
In this tutorial we will show how to use geometries in PINA.
510
Specifically, the tutorial will include how to create geometries and how
611
to visualize them. The topics covered are:
@@ -13,6 +18,15 @@ We import the relevant modules first.
1318

1419
.. code:: ipython3
1520
21+
## routine needed to run the notebook on Google Colab
22+
try:
23+
import google.colab
24+
IN_COLAB = True
25+
except:
26+
IN_COLAB = False
27+
if IN_COLAB:
28+
!pip install "pina-mathlab"
29+
1630
import matplotlib.pyplot as plt
1731
from pina.geometry import EllipsoidDomain, Difference, CartesianDomain, Union, SimplexDomain
1832
from pina.label_tensor import LabelTensor

0 commit comments

Comments
 (0)