Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
adaptive
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Quantum Tinkerer
adaptive
Commits
81a38246
Commit
81a38246
authored
6 years ago
by
Jorn Hoofwijk
Committed by
Bas Nijholt
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
added curvature docs
parent
f68bd816
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!131
Resolve "(Learner1D) add possibility to use the direct neighbors in the loss"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
docs/source/reference/adaptive.learner.learner1D.rst
+6
-0
6 additions, 0 deletions
docs/source/reference/adaptive.learner.learner1D.rst
docs/source/tutorial/tutorial.Learner1D.rst
+58
-0
58 additions, 0 deletions
docs/source/tutorial/tutorial.Learner1D.rst
with
64 additions
and
0 deletions
docs/source/reference/adaptive.learner.learner1D.rst
+
6
−
0
View file @
81a38246
...
...
@@ -12,3 +12,9 @@ Custom loss functions
.. autofunction:: adaptive.learner.learner1D.default_loss
.. autofunction:: adaptive.learner.learner1D.uniform_loss
.. autofunction:: adaptive.learner.learner1D.uses_nth_neighbors
.. autofunction:: adaptive.learner.learner1D.triangle_loss
.. autofunction:: adaptive.learner.learner1D.get_curvature_loss
This diff is collapsed.
Click to expand it.
docs/source/tutorial/tutorial.Learner1D.rst
+
58
−
0
View file @
81a38246
...
...
@@ -137,3 +137,61 @@ functions:
.. jupyter-execute::
runner.live_plot(update_interval=0.1)
Looking at curvature
....................
By default ``adaptive`` will sample more points where the (normalized)
euclidean distance between the neighboring points is large.
You may achieve better results sampling more points in regions with high
curvature. To do this, you need to tell the learner to look at the curvature
by specifying ``loss_per_interval``.
.. jupyter-execute::
from adaptive.learner.learner1D import (get_curvature_loss,
uniform_loss,
default_loss)
curvature_loss = get_curvature_loss()
learner = adaptive.Learner1D(f, bounds=(-1, 1), loss_per_interval=curvature_loss)
runner = adaptive.Runner(learner, goal=lambda l: l.loss() < 0.01)
.. jupyter-execute::
:hide-code:
await runner.task # This is not needed in a notebook environment!
.. jupyter-execute::
runner.live_info()
.. jupyter-execute::
runner.live_plot(update_interval=0.1)
We may see the difference of homogeneous sampling vs only one interval vs
including nearest neighboring intervals in this plot: We will look at 100 points.
.. jupyter-execute::
def sin_exp(x):
from math import exp, sin
return sin(15 * x) * exp(-x**2*2)
learner_h = adaptive.Learner1D(sin_exp, (-1, 1), loss_per_interval=uniform_loss)
learner_1 = adaptive.Learner1D(sin_exp, (-1, 1), loss_per_interval=default_loss)
learner_2 = adaptive.Learner1D(sin_exp, (-1, 1), loss_per_interval=curvature_loss)
npoints_goal = lambda l: l.npoints >= 100
# adaptive.runner.simple is a non parallel blocking runner.
adaptive.runner.simple(learner_h, goal=npoints_goal)
adaptive.runner.simple(learner_1, goal=npoints_goal)
adaptive.runner.simple(learner_2, goal=npoints_goal)
(learner_h.plot().relabel('homogeneous')
+ learner_1.plot().relabel('euclidean loss')
+ learner_2.plot().relabel('curvature loss')).cols(2)
More info about using custom loss functions can be found
in :ref:`Custom adaptive logic for 1D and 2D`.
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment