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

What should learners do when fed the same point twice #39

Closed
basnijholt opened this issue Dec 19, 2018 · 3 comments
Closed

What should learners do when fed the same point twice #39

basnijholt opened this issue Dec 19, 2018 · 3 comments

Comments

@basnijholt
Copy link
Member

(original issue on GitLab)

opened by Joseph Weston (@jbweston) at 2018-09-17T14:44:24.594Z

def tell(self, x, y):
     if x in self.data:
         return

This is what we do for LearnerND (and I think Learner2D also, but I'm not sure).

Does this make sense? In what cases would someone call tell if the point was already evaluated? Would it make more sense to raise an exception because this indicates an error?

If I say

learner.tell(1, 2)
learner.tell(1, 4)

I would either expect:

  • An exception to be raised
  • The new data to overwrite the old data, losses to be updated etc.
@basnijholt
Copy link
Member Author

originally posted by Jorn Hoofwijk (@Jorn) at 2018-09-17T18:26:22.524Z on GitLab

I think it is indeed best practice to just raise an exception, as we should not allow this to happen.

If for some reason I cannot think of, we would need to silently ignore it we could set some variable strict mode (which defaults to True) in the init call, and then if we encounter a double point we will throw an error, unless strict mode is set to False, then we silently ignore

so you would then create a learner by:

learner = LearnerND(func, bounds=[(-1,1),(-1,1)]) # for normal behaviour)
learner = LearnerND(func, bounds=[(-1,1),(-1,1)], strict=False) # for allowing a user to add the same point twice, for whatever reason they would want this

@basnijholt
Copy link
Member Author

originally posted by Anton Akhmerov (@anton-akhmerov) at 2018-09-24T19:22:39.053Z on GitLab

ignore or overwrite?

@basnijholt
Copy link
Member Author

originally posted by Bas Nijholt (@basnijholt) at 2018-12-07T19:44:56.320Z on GitLab

We have decided that we should do the following:

def tell(self, x, y):
    if x in self.data:
        # The point is already evaluated before
        return
    
    # Add point to the data dict
    self.data[x] = y

    # remove from set of pending points
    self.pending_points.discard(x)

    if not self.bounds[0] <= x <= self.bounds[1]:
        # if outside of the domain, stop.
        return

    update_the_other_data_structure_such_as_loss(...)

This is implemented in all the learners ATM.

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

No branches or pull requests

1 participant