question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Epsilon reinitialized when continuing a sampling run

See original GitHub issue

It can be handy to pause a sampling run to print some status information. This is easy to implement via a for-loop:

for i in range(desiredSteps):
   abc.run(max_nr_populations=1)
   # do some other stuff based on the results

However, unfortunately, the adaptive epsilon is always computed based on the very first sample in this case. This is counterintuitive, since everything else seems as if the sampling run is just continued (e.g. t is incremented). Hence, I would expect that epsilon is updated based on the most recent sample.

The reason for this issue is the cached implementation of _get_initial_population:

https://github.com/ICB-DCM/pyABC/blob/913bfcf91ff68a87d8f2b5d6216047f1140b8db3/pyabc/inference/smc.py#L503

Caching like this could be fine if the method would consistently return the very first sample. However, the method takes a t argument, which suggests that it returns the population at a specific time. I am not to judge if this is really an issue, but for the application mentioned above, it would be nice, if the argument t were considered, too, when caching. E.g. the cached value would only be returned if the corresponding t values match.

Quick fix:

To solve the issue for the specific application, setting abc._initial_population = None prior to abc.run solves the problem. It would be nice if this could be done more elegantly, though.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
yannikschaeltecommented, Nov 4, 2021

Thanks 😃 I will try to suggest a modification tomorrow, then it should be on PyPI at the latest some time next week, if that works.

0reactions
samuficommented, Nov 15, 2021

Thank you @yannikschaelte! This looks perfect!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Epsilon 3 Quick Start Guide
The Samples and results to print automatically after measurement frame allows you to select the types of sample results to be printed automatically...
Read more >
Comparing Bandits and Inverse Transform Sampling
Inverse transform sampling allows us to sample from a uniform distribution and map those results to a more interesting distribution.
Read more >
Why does Q-Learning use epsilon-greedy during testing?
In the nature paper they mention: The trained agents were evaluated by playing each game 30 times for up to 5 min each...
Read more >
Emcee Example
We can run the sampler for longer. To do this, we reset the sampler (to get rid of the previous chain) and start...
Read more >
Epsilon Greedy in Deep Q Learning - PyLessons
In this part, we'll cover the Epsilon Greedy method used in Deep Q Learning ... And finally, we are modifying our def run(self):...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found