{"action":"created","issue":{"url":"https://api.github.com/repos/torch/torch7/issues/141","labels_url":"https://api.github.com/repos/torch/torch7/issues/141/labels{/name}","comments_url":"https://api.github.com/repos/torch/torch7/issues/141/comments","events_url":"https://api.github.com/repos/torch/torch7/issues/141/events","html_url":"https://github.com/torch/torch7/pull/141","id":56039954,"number":141,"title":"Make sure RNG is always seeded","user":{"login":"GeorgOstrovski","id":6409187,"avatar_url":"https://avatars.githubusercontent.com/u/6409187?v=3","gravatar_id":"","url":"https://api.github.com/users/GeorgOstrovski","html_url":"https://github.com/GeorgOstrovski","followers_url":"https://api.github.com/users/GeorgOstrovski/followers","following_url":"https://api.github.com/users/GeorgOstrovski/following{/other_user}","gists_url":"https://api.github.com/users/GeorgOstrovski/gists{/gist_id}","starred_url":"https://api.github.com/users/GeorgOstrovski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GeorgOstrovski/subscriptions","organizations_url":"https://api.github.com/users/GeorgOstrovski/orgs","repos_url":"https://api.github.com/users/GeorgOstrovski/repos","events_url":"https://api.github.com/users/GeorgOstrovski/events{/privacy}","received_events_url":"https://api.github.com/users/GeorgOstrovski/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-01-30T14:33:04Z","updated_at":"2015-02-12T01:20:36Z","closed_at":"2015-02-12T01:20:25Z","pull_request":{"url":"https://api.github.com/repos/torch/torch7/pulls/141","html_url":"https://github.com/torch/torch7/pull/141","diff_url":"https://github.com/torch/torch7/pull/141.diff","patch_url":"https://github.com/torch/torch7/pull/141.patch"},"body":"The current way the torch RNG is initialized  (THGenerator_new) creates an invalid (unseeded) first RNG state, which is then lazily seeded in a number of functions depending on a valid state. This is error prone (as was seen previously, where getRNGState would potentially return an invalid state). \r\n\r\nI suggest a minor refactor (thanks to @timharley for the suggestion): THGenerator_newUnseeded is provided as a static function in THRandom.c, so that THRandom_manualSeed which does not need a seeded generator can still obtain an unseeded one. On the other hand, THGenerator_new is changed to always return a seeded generator, so that unseeded generators never leak outside of THRandom.c. The lazy seeding is removed from all places where this was previously needed.\r\n\r\nFurther, THRandom_getState and _setState are removed (their use from within getRNGState and setRNGState has been removed a while ago and they seem deprecated). \r\n\r\n@koraykv \r\n"},"comment":{"url":"https://api.github.com/repos/torch/torch7/issues/comments/74000378","html_url":"https://github.com/torch/torch7/pull/141#issuecomment-74000378","issue_url":"https://api.github.com/repos/torch/torch7/issues/141","id":74000378,"user":{"login":"soumith","id":1310570,"avatar_url":"https://avatars.githubusercontent.com/u/1310570?v=3","gravatar_id":"","url":"https://api.github.com/users/soumith","html_url":"https://github.com/soumith","followers_url":"https://api.github.com/users/soumith/followers","following_url":"https://api.github.com/users/soumith/following{/other_user}","gists_url":"https://api.github.com/users/soumith/gists{/gist_id}","starred_url":"https://api.github.com/users/soumith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/soumith/subscriptions","organizations_url":"https://api.github.com/users/soumith/orgs","repos_url":"https://api.github.com/users/soumith/repos","events_url":"https://api.github.com/users/soumith/events{/privacy}","received_events_url":"https://api.github.com/users/soumith/received_events","type":"User","site_admin":false},"created_at":"2015-02-12T01:20:36Z","updated_at":"2015-02-12T01:20:36Z","body":"thansk Georg, looks good (I think)"}}