phiflow version updates, preparing for 2.2

This commit is contained in:
NT 2022-08-18 13:32:11 +02:00
parent f0032519e1
commit dc64cbf008
9 changed files with 547 additions and 572 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -168,7 +168,7 @@
},
"outputs": [],
"source": [
"!pip install --upgrade --quiet phiflow\n",
"!pip install --upgrade --quiet phiflow==2.1\n",
"#!pip install --upgrade --quiet git+https://github.com/tum-pbs/PhiFlow@develop\n",
"\n",
"from phi.tf.flow import *\n",
@ -1424,4 +1424,4 @@
},
"nbformat": 4,
"nbformat_minor": 0
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -51,11 +51,11 @@ We'll need a few tools for the derivations below, which are summarized here for
Not surprisingly, we'll need some Taylor-series expansions. With the notation above it reads:
$$L(x+\Delta) = L + J^T \Delta + \frac{1}{2} H \Delta^2 + \cdots$$
$$L(x+\Delta) = L + J \Delta + \frac{1}{2} H \Delta^2 + \cdots$$
Then we also need the _Lagrange form_, which yields an exact solution for a $\xi$ from the interval $[x, x+\Delta]$:
$$L(x+\Delta) = L + J^T \Delta + \frac{1}{2} H(\xi) \Delta^2$$
$$L(x+\Delta) = L + J \Delta + \frac{1}{2} H(\xi) \Delta^2$$
In several instances we'll make use of the fundamental theorem of calculus, repeated here for completeness:
@ -134,27 +134,27 @@ with lower loss values.
First, we apply the fundamental theorem to L
$$
L(x + \lambda \Delta) = L + \int_0^1 \text{ds}~ J^T(x + s \lambda \Delta) \lambda \Delta \ ,
L(x + \lambda \Delta) = L + \int_0^1 \text{ds}~ J(x + s \lambda \Delta) \lambda \Delta \ ,
$$
and likewise express $J$ around this location with it:
$$\begin{aligned}
J^T(x + s \lambda \Delta) &= J^T + \int_0^1 \text{dt}~ H(x + s t \lambda \Delta) s \lambda \Delta
J(x + s \lambda \Delta) = J + s \lambda \Delta^T \int_0^1 \text{dt}~ H(x + s t \lambda \Delta)
\end{aligned}$$
Inserting this $J^T$ into $L$ yields:
$$\begin{aligned}
L(x + \lambda \Delta) - L(x)
&= \int_0^1 \text{d}s \Big[ J^T + \int_0^1 \text{d}t~ H(x + s t \lambda \Delta) ~ s \lambda \Delta \Big]^T \lambda \Delta \\
&= \int_0^1 \text{d}s \Big[ J + s \lambda \Delta^T \int_0^1 \text{d}t~ H(x + s t \lambda \Delta) \Big]^T \lambda \Delta \\
&= \int_0^1 \text{d}s \Big[ -H \Delta + \int_0^1 \text{d}t H(x + s t \lambda \Delta) ~ s \lambda \Delta \Big]^T \lambda \Delta \\
&= \int_0^1 \text{d}s \int_0^1 \text{d}t \big[ -H \Delta + H(x + s t \lambda \Delta) ~ s \lambda \Delta \big]^T \lambda \Delta \\
&= \int_0^1 \text{d}s \int_0^1 \text{d}t \big[ -H \Delta (1+\lambda s) + [ H(x + s t \lambda \Delta) - H ] ~ s \lambda \Delta \big]^T \lambda \Delta \\
&= -(H\Delta)^T \big( 1+\frac{\lambda}{2} \big) \lambda \Delta + \lambda^2 \int_0^1 \text{d}s ~ s \int_0^1 \text{d}t \big[ [ H(x + s t \lambda \Delta) - H ] ~ \Delta \big]^T \Delta \\
\end{aligned}$$ (newton-step-size-conv1)
Here we've first used $\Delta = - J^T/H$, and moved it into the integral in the third line.
Here we've first used $\Delta = - J^T/H$, and moved it into the integral in the third line, alongside the $s \lambda \Delta$ term.
Line four factors out $H \Delta$. This allows us to evaluate the integral for the first term
$ -H \Delta (1+\lambda s)$ in the last line of equation {eq}`newton-step-size-conv1` above.

View File

@ -67,7 +67,8 @@
},
"outputs": [],
"source": [
"!pip install --upgrade --quiet git+https://github.com/tum-pbs/PhiFlow\n",
"!pip install --upgrade --quiet phiflow==2.2\n",
"#!pip install --upgrade --quiet git+https://github.com/tum-pbs/PhiFlow\n",
"from phi.torch.flow import * # switch to TF with \"phi.tf.flow\""
]
},

View File

@ -785,12 +785,9 @@
"metadata": {
"colab": {
"collapsed_sections": [],
"name": "LinearChain_GD_PG_HIG-fromSlack-colab.ipynb",
"name": "physgrad-hig-code.ipynb",
"provenance": []
},
"interpreter": {
"hash": "60a46218545510a486eb79ffac0761a327b44b02462576ac242e6c15f2abc4b7"
},
"kernelspec": {
"display_name": "Python 3.8.10 64-bit ('tf250': conda)",
"name": "python3"

View File

@ -74,23 +74,6 @@
"name": "stderr",
"output_type": "stream",
"text": []
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Could not load resample cuda libraries: CUDA binaries not found at /Users/thuerey/Dropbox/mbaDevelSelected/phiflow-v1.5/phi/tf/cuda/build/resample.so. Run \"python setup.py cuda\" to compile them\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
" for key in self._mapping:\n",
" yield (key, self._mapping[key])\n",
"$ python setup.py tf_cuda\n",
"before reinstalling phiflow.\n"
]
}
],
"source": [
@ -210,10 +193,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Instructions for updating:\n",
"Use keras.layers.Dense instead.\n",
"Instructions for updating:\n",
"Please use `layer.__call__` method instead.\n"
"\n"
]
}
],