Automatize Tutorials html, py files creation (#496)
* workflow to export tutorials ---------
This commit is contained in:
committed by
Nicola Demo
parent
aea24d0bee
commit
0146155c9b
31
tutorials/tutorial13/tutorial.ipynb
vendored
31
tutorials/tutorial13/tutorial.ipynb
vendored
@@ -25,12 +25,13 @@
|
||||
"source": [
|
||||
"## routine needed to run the notebook on Google Colab\n",
|
||||
"try:\n",
|
||||
" import google.colab\n",
|
||||
" IN_COLAB = True\n",
|
||||
" import google.colab\n",
|
||||
"\n",
|
||||
" IN_COLAB = True\n",
|
||||
"except:\n",
|
||||
" IN_COLAB = False\n",
|
||||
" IN_COLAB = False\n",
|
||||
"if IN_COLAB:\n",
|
||||
" !pip install \"pina-mathlab\"\n",
|
||||
" !pip install \"pina-mathlab\"\n",
|
||||
"\n",
|
||||
"import torch\n",
|
||||
"import matplotlib.pyplot as plt\n",
|
||||
@@ -46,7 +47,7 @@
|
||||
"from pina.model import FeedForward\n",
|
||||
"from pina.model.block import FourierFeatureEmbedding\n",
|
||||
"\n",
|
||||
"warnings.filterwarnings('ignore')"
|
||||
"warnings.filterwarnings(\"ignore\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -312,9 +313,13 @@
|
||||
"l2_loss = LpLoss(p=2, relative=False)\n",
|
||||
"\n",
|
||||
"# sample new test points\n",
|
||||
"pts = pts = problem.spatial_domain.sample(100, 'grid')\n",
|
||||
"print(f'Relative l2 error PINN {l2_loss(pinn(pts), problem.solution(pts)).item():.2%}')\n",
|
||||
"print(f'Relative l2 error SAPINN {l2_loss(sapinn(pts), problem.solution(pts)).item():.2%}')"
|
||||
"pts = pts = problem.spatial_domain.sample(100, \"grid\")\n",
|
||||
"print(\n",
|
||||
" f\"Relative l2 error PINN {l2_loss(pinn(pts), problem.solution(pts)).item():.2%}\"\n",
|
||||
")\n",
|
||||
"print(\n",
|
||||
" f\"Relative l2 error SAPINN {l2_loss(sapinn(pts), problem.solution(pts)).item():.2%}\"\n",
|
||||
")"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -462,12 +467,14 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"#plot solution obtained\n",
|
||||
"plot_solution(multiscale_pinn, 'Multiscale PINN solution')\n",
|
||||
"# plot solution obtained\n",
|
||||
"plot_solution(multiscale_pinn, \"Multiscale PINN solution\")\n",
|
||||
"\n",
|
||||
"# sample new test points\n",
|
||||
"pts = pts = problem.spatial_domain.sample(100, 'grid')\n",
|
||||
"print(f'Relative l2 error PINN with MultiscaleFourierNet: {l2_loss(multiscale_pinn(pts), problem.solution(pts)).item():.2%}')"
|
||||
"pts = pts = problem.spatial_domain.sample(100, \"grid\")\n",
|
||||
"print(\n",
|
||||
" f\"Relative l2 error PINN with MultiscaleFourierNet: {l2_loss(multiscale_pinn(pts), problem.solution(pts)).item():.2%}\"\n",
|
||||
")"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user