Skip to content

Commit 626ac6d

Browse files
authored
add learner1D.abs_min_log_loss (#294)
1 parent c8895ed commit 626ac6d

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

adaptive/learner/learner1D.py

+7
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ def default_loss(xs, ys):
5151
return np.hypot(dx, dy)
5252

5353

54+
@uses_nth_neighbors(0)
55+
def abs_min_log_loss(xs, ys):
56+
"""Calculate loss of a single interval that prioritizes the absolute minimum."""
57+
ys = [np.log(np.abs(y).min()) for y in ys]
58+
return default_loss(xs, ys)
59+
60+
5461
@uses_nth_neighbors(1)
5562
def triangle_loss(xs, ys):
5663
xs = [x for x in xs if x is not None]

docs/source/tutorial/tutorial.custom_loss.rst

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ tl;dr, one can use the following *loss functions* that
4747
+ `adaptive.learner.learner1D.default_loss`
4848
+ `adaptive.learner.learner1D.uniform_loss`
4949
+ `adaptive.learner.learner1D.curvature_loss_function`
50+
+ `adaptive.learner.learner1D.abs_min_log_loss`
5051
+ `adaptive.learner.learner2D.default_loss`
5152
+ `adaptive.learner.learner2D.uniform_loss`
5253
+ `adaptive.learner.learner2D.minimize_triangle_surface_loss`

0 commit comments

Comments
 (0)