Skip to content

Learner1D.ask breaks when adding points in some order #41

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

Closed
basnijholt opened this issue Dec 19, 2018 · 1 comment
Closed

Learner1D.ask breaks when adding points in some order #41

basnijholt opened this issue Dec 19, 2018 · 1 comment

Comments

@basnijholt
Copy link
Member

(original issue on GitLab)

opened by Bas Nijholt (@basnijholt) at 2018-09-14T11:16:49.789Z

l = adaptive.Learner1D(lambda x: x, (0, 1))
l.tell_many([1, 0, 0.5], [0, 0, 0])
l.ask(1)

Traceback

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-17-1b520d635f37> in <module>()
      2 l = adaptive.Learner1D(lambda x: x, (0, 1))
      3 l.tell_many([1, 0, 0.5], [0, 0, 0])
----> 4 l.ask(1)

~/Work/adaptive/adaptive/learner/learner1D.py in ask(self, n, add_data)
    301                      in self.neighbors.items()][:-1]
    302 
--> 303         for x_left, x_right in intervals:
    304             self.losses[x_left, x_right] = (
    305                 self.loss_per_interval((x_left, x_right), self._scale, self.data)

~/Work/adaptive/adaptive/learner/base_learner.py in tell_many(self, xs, ys)
     43         """
     44         for x, y in zip(xs, ys):
---> 45             self.tell(x, y)
     46 
     47     @abc.abstractmethod

~/Work/adaptive/adaptive/learner/learner1D.py in tell(self, x, y)
    239         self.update_scale(x, y)
    240 
--> 241         # Update the losses
    242         self.update_losses(x, real)
    243 

~/Work/adaptive/adaptive/learner/learner1D.py in update_losses(self, x, real)
    159             a, b = self.find_neighbors(x, self.neighbors_combined)
    160             if x_left is not None and x_right is not None:
--> 161                 dx = x_right - x_left
    162                 loss = self.losses[x_left, x_right]
    163                 losses_combined[a, x] = (x - a) * loss / dx

KeyError: (0, 1)
@basnijholt
Copy link
Member Author

originally posted by Bas Nijholt (@basnijholt) at 2018-09-14T11:21:51.304Z on GitLab

This is probably related to gitlab:#97.

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

No branches or pull requests

1 participant