... | ... |
@@ -253,13 +253,13 @@ |
253 | 253 |
"metadata": {}, |
254 | 254 |
"outputs": [], |
255 | 255 |
"source": [ |
256 |
- "def func(arg):\n", |
|
256 |
+ "def func(xy):\n", |
|
257 | 257 |
" import numpy as np\n", |
258 |
- " x, y = arg\n", |
|
258 |
+ " x, y = xy\n", |
|
259 | 259 |
" a = 0.2\n", |
260 |
- " return np.exp(-(x**2 + y**2 - 0.75**2)**2/a**4)\n", |
|
260 |
+ " return x + np.exp(-(x**2 + y**2 - 0.75**2)**2/a**4)\n", |
|
261 | 261 |
"\n", |
262 |
- "learner = adaptive.learner.AdaptiveTriSampling(func, bounds=[(-1, 1), (-1, 1)])" |
|
262 |
+ "learner = adaptive.learner.Learner2D(func, bounds=[(-1, 1), (-1, 1)])" |
|
263 | 263 |
] |
264 | 264 |
}, |
265 | 265 |
{ |
... | ... |
@@ -269,8 +269,8 @@ |
269 | 269 |
"outputs": [], |
270 | 270 |
"source": [ |
271 | 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)" |
|
272 |
+ "executor = ProcessPoolExecutor(max_workers=48)\n", |
|
273 |
+ "runner = adaptive.Runner(learner, executor, goal=lambda l: l.loss() > 1500, log=True)" |
|
274 | 274 |
] |
275 | 275 |
}, |
276 | 276 |
{ |
... | ... |
@@ -282,6 +282,20 @@ |
282 | 282 |
"adaptive.live_plot(runner)" |
283 | 283 |
] |
284 | 284 |
}, |
285 |
+ { |
|
286 |
+ "cell_type": "code", |
|
287 |
+ "execution_count": null, |
|
288 |
+ "metadata": {}, |
|
289 |
+ "outputs": [], |
|
290 |
+ "source": [ |
|
291 |
+ "import numpy as np\n", |
|
292 |
+ "learner2 = adaptive.learner.Learner2D(func, bounds=[(-1, 1), (-1, 1)])\n", |
|
293 |
+ "lin = np.linspace(-1, 1, len(learner.points)**0.5)\n", |
|
294 |
+ "xy = [(x, y) for x in lin for y in lin]\n", |
|
295 |
+ "learner2.add_data(xy, map(func, xy))\n", |
|
296 |
+ "learner2.plot().relabel('Homogeneous grid') + learner.plot().relabel('With adaptive')" |
|
297 |
+ ] |
|
298 |
+ }, |
|
285 | 299 |
{ |
286 | 300 |
"cell_type": "markdown", |
287 | 301 |
"metadata": { |