Updated user guide accordingly.
"cell_type": "markdown",
"metadata": {},
"source": [
- "`solve` returns a tuple, where the first entry is the solution as a function and the second entry is the loss history as a list. The solution is a function that maps $t$ to $x$. It accepts `numpy.array` as input as well. Here we compare the ANN-based solution with the analytical solution:"
+ "`solve` returns a tuple, where the first entry is the solution as a function and the second entry is the loss history as a list. The solution is a function that maps $t$ to $x$. It accepts `numpy.array` as input as well. The default return type of the solution is `torch.tensor`. If we wanted to return `numpy.array`, we can specify `as_type='np'`. Here we compare the ANN-based solution with the analytical solution:"
]
},
{
],
"source": [
"ts = np.linspace(0, 2.0, 100)\n",
- "x_net = solution_ex(ts)\n",
+ "x_net = solution_ex(ts, as_type='np')\n",
"x_ana = np.exp(-ts)\n",
"\n",
"plt.figure()\n",
],
"source": [
"ts = np.linspace(0, 2*np.pi, 100)\n",
- "x_net = solution_ho(ts)\n",
+ "x_net = solution_ho(ts, as_type='np')\n",
"x_ana = np.sin(ts)\n",
"\n",
"plt.figure()\n",
],
"source": [
"ts = np.linspace(0, 2*np.pi, 100)\n",
- "x1_net, x2_net = solution_pc(ts)\n",
+ "x1_net, x2_net = solution_pc(ts, as_type='np')\n",
"x1_ana, x2_ana = np.sin(ts), np.cos(ts)\n",
"\n",
"plt.figure()\n",
"ts = np.linspace(0, 12, 100)\n",
"\n",
"# ANN-based solution\n",
- "prey_net, pred_net = solution_lv(ts)\n",
+ "prey_net, pred_net = solution_lv(ts, as_type='np')\n",
"\n",
"# numerical solution\n",
"from scipy.integrate import odeint\n",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.6.8"
+ "version": "3.6.7"
}
},
"nbformat": 4,
