File tree 1 file changed +20
-0
lines changed
1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,26 @@ on the *Play* :fa:`play` button or move the sliders.
50
50
`adaptive.Learner1D `
51
51
~~~~~~~~~~~~~~~~~~~~
52
52
53
+ Adaptively learning a 1D function (the plot below) and live-plotting the process in a Jupyter notebook is as easy as
54
+
55
+ .. code :: python
56
+
57
+ from adaptive import notebook_extension, Runner, Learner1D
58
+ notebook_extension() # enables notebook integration
59
+
60
+ def peak (x , a = 0.01 ): # function to "learn"
61
+ return x + a** 2 / (a** 2 + x** 2 )
62
+
63
+ learner = Learner1D(peak, bounds = (- 1 , 1 ))
64
+
65
+ def goal (learner ):
66
+ return learner.loss() < 0.01 # continue until loss is small enough
67
+
68
+ runner = Runner(learner, goal) # start calculation on all CPU cores
69
+ runner.live_info() # shows a widget with status information
70
+ runner.live_plot()
71
+
72
+
53
73
.. jupyter-execute ::
54
74
:hide-code:
55
75
You can’t perform that action at this time.
0 commit comments