adaptive icon indicating copy to clipboard operation
adaptive copied to clipboard

Introduce "Learner not ready" error

Open basnijholt opened this issue 6 years ago • 2 comments

(original issue on GitLab)

opened by Anton Akhmerov (@anton-akhmerov) at 2018-03-10T20:58:36.245Z

Some adaptive algorithms may be implemented such that they are not ready to request new data until more data arrives. While this reduces the suitability of these algorithms to parallelization, there is no reason to prohibit it.

We could handle this as follows:

  • Introduce an InsufficientData error (name is tentative) that could be a subclass of StopIteration if we view learners as iterators (see gitlab:#45).
  • Teach the runners and BalancingLearner to catch this error and only resume querying the learner after they supply additional data.

That way we could even write a trivial wrapper learner that works with any adaptive algorithm and blocks on every step.

basnijholt avatar Dec 19 '18 16:12 basnijholt

originally posted by Christoph Groth (@cwg) at 2018-04-20T12:17:06.858Z on GitLab

Wouldn't returning None when new points are requested be more natural? StopIteration has the meaning that iteration over this iterator is finished, so your proposal would require getting a new iterator from the learner once data has been fed back. That seems strange.

Consider evaluating the same function with the same deterministic learner but with different resources. The result of the learning will be the same in all cases. It seems strange to couple the lifetime of iterators to the availability of resources.

To me, a more natural use of StopIteration is to allow the learner to signal the runner when the a precision condition is met (when specified, the default should be infinite iteration).

While it can be useful to have custom conditions or even run the learner until it is stopped manually, very often some criterion of precision can be specified upfront. (Think of adaptive integration which is currently the most commonly used case of adaptive evaluation.) I have the impression that the learner is the best place to evaluate whether such criteria are reached or not.

basnijholt avatar Dec 19 '18 16:12 basnijholt

originally posted by Anton Akhmerov (@anton-akhmerov) at 2018-04-20T12:19:20.860Z on GitLab

You're right, returning None is a more intuitive interface for indicating that the learner isn't ready.

basnijholt avatar Dec 19 '18 16:12 basnijholt