Skip to content
Snippets Groups Projects

Resolve "(Learner1D) add possibility to use the direct neighbors in the loss"

Merged Jorn Hoofwijk requested to merge 119-add-second-order-loss-to-adaptive into master
Compare and Show latest version
1 file
+ 3
5
Compare changes
  • Side-by-side
  • Inline
@@ -66,18 +66,16 @@ def _loss_of_multi_interval(xs, ys):
def triangle_loss(interval, neighbours, scale, function_values):
x_left, x_right = interval
neighbour_left, neighbour_right = neighbours
x_scale, y_scale = scale
dx = (x_right - x_left) / x_scale
xs = [neighbour_left, x_left, x_right, neighbour_right]
# The neighbours could be None if we are at the boundary, in that case we
# have to filter this out
xs = [x for x in xs if x is not None]
y_scale = y_scale or 1
y_scale = scale[1] or 1
ys = [function_values[x] / y_scale for x in xs]
xs = [x / x_scale for x in xs]
xs = [x / scale[0] for x in xs]
if len(xs) <= 2:
return dx
return (x_right - x_left) / scale[0]
else:
return _loss_of_multi_interval(xs, ys)
Loading