phiflow version updates, preparing for 2.2
This commit is contained in:
parent
f0032519e1
commit
dc64cbf008
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -168,7 +168,7 @@
|
|||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"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",
|
"#!pip install --upgrade --quiet git+https://github.com/tum-pbs/PhiFlow@develop\n",
|
||||||
"\n",
|
"\n",
|
||||||
"from phi.tf.flow import *\n",
|
"from phi.tf.flow import *\n",
|
||||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -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:
|
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]$:
|
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:
|
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
|
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:
|
and likewise express $J$ around this location with it:
|
||||||
|
|
||||||
$$\begin{aligned}
|
$$\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}$$
|
\end{aligned}$$
|
||||||
|
|
||||||
Inserting this $J^T$ into $L$ yields:
|
Inserting this $J^T$ into $L$ yields:
|
||||||
|
|
||||||
$$\begin{aligned}
|
$$\begin{aligned}
|
||||||
L(x + \lambda \Delta) - L(x)
|
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 \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 + 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 \\
|
&= \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 \\
|
&= -(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)
|
\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
|
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.
|
$ -H \Delta (1+\lambda s)$ in the last line of equation {eq}`newton-step-size-conv1` above.
|
||||||
|
|
||||||
|
@ -67,7 +67,8 @@
|
|||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"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\""
|
"from phi.torch.flow import * # switch to TF with \"phi.tf.flow\""
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -785,12 +785,9 @@
|
|||||||
"metadata": {
|
"metadata": {
|
||||||
"colab": {
|
"colab": {
|
||||||
"collapsed_sections": [],
|
"collapsed_sections": [],
|
||||||
"name": "LinearChain_GD_PG_HIG-fromSlack-colab.ipynb",
|
"name": "physgrad-hig-code.ipynb",
|
||||||
"provenance": []
|
"provenance": []
|
||||||
},
|
},
|
||||||
"interpreter": {
|
|
||||||
"hash": "60a46218545510a486eb79ffac0761a327b44b02462576ac242e6c15f2abc4b7"
|
|
||||||
},
|
|
||||||
"kernelspec": {
|
"kernelspec": {
|
||||||
"display_name": "Python 3.8.10 64-bit ('tf250': conda)",
|
"display_name": "Python 3.8.10 64-bit ('tf250': conda)",
|
||||||
"name": "python3"
|
"name": "python3"
|
||||||
|
@ -74,23 +74,6 @@
|
|||||||
"name": "stderr",
|
"name": "stderr",
|
||||||
"output_type": "stream",
|
"output_type": "stream",
|
||||||
"text": []
|
"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": [
|
"source": [
|
||||||
@ -210,10 +193,7 @@
|
|||||||
"name": "stdout",
|
"name": "stdout",
|
||||||
"output_type": "stream",
|
"output_type": "stream",
|
||||||
"text": [
|
"text": [
|
||||||
"Instructions for updating:\n",
|
"\n"
|
||||||
"Use keras.layers.Dense instead.\n",
|
|
||||||
"Instructions for updating:\n",
|
|
||||||
"Please use `layer.__call__` method instead.\n"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
Loading…
Reference in New Issue
Block a user