File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -50,6 +50,26 @@ on the *Play* :fa:`play` button or move the sliders.
5050`adaptive.Learner1D `
5151~~~~~~~~~~~~~~~~~~~~
5252
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+
5373 .. jupyter-execute ::
5474 :hide-code:
5575
You can’t perform that action at this time.
0 commit comments