{"action":"created","issue":{"url":"https://api.github.com/repos/lisa-lab/pylearn2/issues/1449","labels_url":"https://api.github.com/repos/lisa-lab/pylearn2/issues/1449/labels{/name}","comments_url":"https://api.github.com/repos/lisa-lab/pylearn2/issues/1449/comments","events_url":"https://api.github.com/repos/lisa-lab/pylearn2/issues/1449/events","html_url":"https://github.com/lisa-lab/pylearn2/issues/1449","id":64071497,"number":1449,"title":"Wrong termination behaviour of MonitorBased TerminationCriterion","user":{"login":"riga","id":1908734,"avatar_url":"https://avatars.githubusercontent.com/u/1908734?v=3","gravatar_id":"","url":"https://api.github.com/users/riga","html_url":"https://github.com/riga","followers_url":"https://api.github.com/users/riga/followers","following_url":"https://api.github.com/users/riga/following{/other_user}","gists_url":"https://api.github.com/users/riga/gists{/gist_id}","starred_url":"https://api.github.com/users/riga/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/riga/subscriptions","organizations_url":"https://api.github.com/users/riga/orgs","repos_url":"https://api.github.com/users/riga/repos","events_url":"https://api.github.com/users/riga/events{/privacy}","received_events_url":"https://api.github.com/users/riga/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-03-24T18:49:26Z","updated_at":"2015-03-24T20:27:56Z","closed_at":null,"body":"The termination behaviour of the MonitorBased TerminationCriterion does not match the expectation I get from reading the docstring. It says:\r\n\r\n```\r\nA termination criterion that pulls out the specified channel in\r\nthe model's monitor and checks to see if it has decreased by a\r\ncertain proportion of the lowest value in the last N epochs.\r\n```\r\n\r\nThe code is the following:\r\n\r\n```python\r\n# v[-1] is the last monitored value\r\n# first if-clause\r\nif v[-1] < (1. - self.prop_decrease) * self.best_value:\r\n    self.countdown = self.N\r\nelse:\r\n    self.countdown = self.countdown - 1\r\n\r\n# second if-clause\r\nif v[-1] < self.best_value:\r\n    self.best_value = v[-1]\r\n```\r\n\r\nI'll try to explain the problem a see here with a short example:\r\n\r\nAssume you require a ``prop_decrease`` of 10% within the last 10 epochs. Now, your objective function starts at 1.0 and decreases by 9% in each epoch relative to the previous one.\r\n\r\nAfter the *first* epoch (``v[-1] = 0.91``), the first if-clause is false (since ``0.91 < (1. - 0.1) * 1.0`` is false). However, the second if-clause is true (since ``0.91 < 1.0`` is true) and thus, ``best_value`` is set to 0.91.\r\n\r\nAfter the *second* epoch (``v[-1] = 0.828..``), the first if-clause is still false (since ``0.828 < (1. - 0.1) * 0.91`` is false). Again, due to the second if-clause, ``best_value`` is updated to 0.828.\r\n\r\nThe same procedure applies to all subsequent epochs until ``countdown`` approaches zero, which will happen after epoch 10. At that time, the value of the objective function (``v[-1]``) is ~ 0.39, i.e. a decrease of 61% of the initial value. So we saw the \"decrease of 10% within the last 10 epochs\". I think the problem is the second if-clause and the update of ``best_value``. It should be moved to the first if-clause to accomplish the desired behaviour.\r\n\r\nIn fact, the code used to be correct, but was \"fixed\" ;-) [here](https://github.com/lisa-lab/pylearn2/commit/bff8fd2cea87f3a7e6320a2868a981ab63c74c1f) 2 1/2 years ago.\r\n\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/lisa-lab/pylearn2/issues/comments/85679149","html_url":"https://github.com/lisa-lab/pylearn2/issues/1449#issuecomment-85679149","issue_url":"https://api.github.com/repos/lisa-lab/pylearn2/issues/1449","id":85679149,"user":{"login":"lamblin","id":178249,"avatar_url":"https://avatars.githubusercontent.com/u/178249?v=3","gravatar_id":"","url":"https://api.github.com/users/lamblin","html_url":"https://github.com/lamblin","followers_url":"https://api.github.com/users/lamblin/followers","following_url":"https://api.github.com/users/lamblin/following{/other_user}","gists_url":"https://api.github.com/users/lamblin/gists{/gist_id}","starred_url":"https://api.github.com/users/lamblin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lamblin/subscriptions","organizations_url":"https://api.github.com/users/lamblin/orgs","repos_url":"https://api.github.com/users/lamblin/repos","events_url":"https://api.github.com/users/lamblin/events{/privacy}","received_events_url":"https://api.github.com/users/lamblin/received_events","type":"User","site_admin":false},"created_at":"2015-03-24T20:27:56Z","updated_at":"2015-03-24T20:27:56Z","body":"Thanks.\r\n@riga if you want to submit a pull request making that more clear, that would be welcome."}}