Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: allow the loss to be a tuple in the Learner1D #154

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

basnijholt
Copy link
Member

@basnijholt basnijholt commented Mar 8, 2019

Still very much a WIP:

import adaptive
import numpy as np
import random

offset = random.uniform(-0.5, 0.5)

def f(x, offset=offset):
    a = 0.01
    return x + a**2 / (a**2 + (x - offset)**2)

@adaptive.learner.learner1D.uses_nth_neighbors(0)
@adaptive.learner.learner1D.loss_returns(tuple, 2)
def uniform_loss(xs, ys):
    dx = xs[1] - xs[0]
    return dx, dx

learner = adaptive.Learner1D(f, bounds=(-1, 1), loss_per_interval=uniform_loss)

learner.loss()

adaptive.runner.simple(learner, lambda l: l.loss() < (0.01, 0.01))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant