Browse code

add 2D learner to the notebook

Bas Nijholt authored on 05/09/2017 21:41:42
Showing 1 changed files
... ...
@@ -240,6 +240,48 @@
240 240
     "adaptive.live_plot(runner, plotter=lambda learner: hv.Overlay([L.plot() for L in learner.learners]))"
241 241
    ]
242 242
   },
243
+  {
244
+   "cell_type": "markdown",
245
+   "metadata": {},
246
+   "source": [
247
+    "# 2D learner"
248
+   ]
249
+  },
250
+  {
251
+   "cell_type": "code",
252
+   "execution_count": null,
253
+   "metadata": {},
254
+   "outputs": [],
255
+   "source": [
256
+    "def func(arg):\n",
257
+    "    import numpy as np\n",
258
+    "    x, y = arg\n",
259
+    "    a = 0.2\n",
260
+    "    return np.exp(-(x**2 + y**2 - 0.75**2)**2/a**4)\n",
261
+    "\n",
262
+    "learner = adaptive.learner.AdaptiveTriSampling(func, bounds=[(-1, 1), (-1, 1)])"
263
+   ]
264
+  },
265
+  {
266
+   "cell_type": "code",
267
+   "execution_count": null,
268
+   "metadata": {},
269
+   "outputs": [],
270
+   "source": [
271
+    "from concurrent.futures import ProcessPoolExecutor\n",
272
+    "executor = ProcessPoolExecutor(max_workers=2)\n",
273
+    "runner = adaptive.Runner(learner, executor, goal=lambda l: l.loss() > 2000)"
274
+   ]
275
+  },
276
+  {
277
+   "cell_type": "code",
278
+   "execution_count": null,
279
+   "metadata": {},
280
+   "outputs": [],
281
+   "source": [
282
+    "adaptive.live_plot(runner)"
283
+   ]
284
+  },
243 285
   {
244 286
    "cell_type": "markdown",
245 287
    "metadata": {