{"action":"created","comment":{"url":"https://api.github.com/repos/saleml/pgm-rws/pulls/comments/238888041","pull_request_review_id":181540241,"id":238888041,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzODg4ODA0MQ==","diff_hunk":"@@ -1,61 +1,65 @@\n import torch\n+from torch.distributions import Normal\n+from torch.distributions.one_hot_categorical import OneHotCategorical\n+import numpy as np\n+\n from torch import nn\n \n from rws.model import BasicModel\n \n \n-class RWS_1 (nn.Module):\n+class RWS_1(object):\n     '''\n     INPUT ARGUMENTS\n \n-    input_dim : input dimension (eg 784 for mini MNSIT)\n+    model : the model to use\n     K : number of particles\n-    hidden_dim : hidden dimension (default = 200)\n-    hidden_layers : number of hidden layers (as described in BasicModel)\n-    encoding_dim : latent code dimension (default = 50)\n-    hidden_nonlinearity : hidden non linearity (default = tanh)\n-    decoder_nonlinearity : decoder non linearity (default = sigmoid)\n+    optim_recog : optimizer of recognition network\n+    optim_model : optimizer of model\n+    mode : 'MNIST', 'dis-GMM', 'cont-GMM'\n \n     OUTPUT :\n \n     RWS algo object with a model attribute\n     train step : performs model update, q wake update q sleep update\n \n     '''\n-    def __init__(self,input_dim , K=1,hidden_dim=200, hidden_layers=1, encoding_dim=50, hidden_nonlinearity='tanh',\n-                 decoder_nonlinearity='sigmoid'):\n+\n+    def __init__(self, model, optim_recog, optim_model, K=1, mode='MNIST'):\n         super(RWS_1, self).__init__()\n-        self.model = BasicModel(input_dim,hidden_dim,hidden_layers,encoding_dim,hidden_nonlinearity,decoder_nonlinearity)\n+        self.model = model\n+        self.optim_recog = optim_recog\n+        self.optim_model = optim_model\n         self.K = K\n-    def forward(self,X):\n-        (sample, mu, sigma), p = self.model(X)\n-        return sample, mu, 2*torch.log(sigma),p\n+        self.mode = mode\n+\n+    def forward(self, X):\n+        (sample, mu, sigma), (model_sample, model_mu, model_sigma) = self.model(X)\n+        return sample, mu, 2 * torch.log(sigma), model_sample, model_mu, 2 * torch.log(model_sigma)\n \n     def get_loss_p_update(self, mean, logvar, input):\n \n-        log_weights = torch.zeros((input.size()[0],self.K))\n-        log_ps = torch.zeros((input.size()[0],self.K))\n+        log_weights = torch.zeros((input.size()[0], self.K))\n+        log_ps = torch.zeros((input.size()[0], self.K))\n \n         for i in range(self.K):\n             log_weight, log_q, log_p = self.get_importance_weight_gauss(mean, logvar, input)","path":"rws/RWS.py","position":61,"original_position":61,"commit_id":"a194fd1992497e581ac70f537b4744ea203179ed","original_commit_id":"a194fd1992497e581ac70f537b4744ea203179ed","user":{"login":"saleml","id":16039448,"node_id":"MDQ6VXNlcjE2MDM5NDQ4","avatar_url":"https://avatars2.githubusercontent.com/u/16039448?v=4","gravatar_id":"","url":"https://api.github.com/users/saleml","html_url":"https://github.com/saleml","followers_url":"https://api.github.com/users/saleml/followers","following_url":"https://api.github.com/users/saleml/following{/other_user}","gists_url":"https://api.github.com/users/saleml/gists{/gist_id}","starred_url":"https://api.github.com/users/saleml/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saleml/subscriptions","organizations_url":"https://api.github.com/users/saleml/orgs","repos_url":"https://api.github.com/users/saleml/repos","events_url":"https://api.github.com/users/saleml/events{/privacy}","received_events_url":"https://api.github.com/users/saleml/received_events","type":"User","site_admin":false},"body":"not defined","created_at":"2018-12-05T00:06:04Z","updated_at":"2018-12-05T00:06:04Z","html_url":"https://github.com/saleml/pgm-rws/pull/7#discussion_r238888041","pull_request_url":"https://api.github.com/repos/saleml/pgm-rws/pulls/7","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/saleml/pgm-rws/pulls/comments/238888041"},"html":{"href":"https://github.com/saleml/pgm-rws/pull/7#discussion_r238888041"},"pull_request":{"href":"https://api.github.com/repos/saleml/pgm-rws/pulls/7"}}},"pull_request":{"url":"https://api.github.com/repos/saleml/pgm-rws/pulls/7","id":235996833,"node_id":"MDExOlB1bGxSZXF1ZXN0MjM1OTk2ODMz","html_url":"https://github.com/saleml/pgm-rws/pull/7","diff_url":"https://github.com/saleml/pgm-rws/pull/7.diff","patch_url":"https://github.com/saleml/pgm-rws/pull/7.patch","issue_url":"https://api.github.com/repos/saleml/pgm-rws/issues/7","number":7,"state":"open","locked":false,"title":"fix model in args + different modes (Bernouilli and GMM) handled","user":{"login":"rimassouel","id":17125995,"node_id":"MDQ6VXNlcjE3MTI1OTk1","avatar_url":"https://avatars3.githubusercontent.com/u/17125995?v=4","gravatar_id":"","url":"https://api.github.com/users/rimassouel","html_url":"https://github.com/rimassouel","followers_url":"https://api.github.com/users/rimassouel/followers","following_url":"https://api.github.com/users/rimassouel/following{/other_user}","gists_url":"https://api.github.com/users/rimassouel/gists{/gist_id}","starred_url":"https://api.github.com/users/rimassouel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rimassouel/subscriptions","organizations_url":"https://api.github.com/users/rimassouel/orgs","repos_url":"https://api.github.com/users/rimassouel/repos","events_url":"https://api.github.com/users/rimassouel/events{/privacy}","received_events_url":"https://api.github.com/users/rimassouel/received_events","type":"User","site_admin":false},"body":"différent models handled in RWS algo (mode argument) ","created_at":"2018-12-04T23:34:43Z","updated_at":"2018-12-05T00:06:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"be0ca1f24dcd0e5da1af911518ba2d171622759c","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/saleml/pgm-rws/pulls/7/commits","review_comments_url":"https://api.github.com/repos/saleml/pgm-rws/pulls/7/comments","review_comment_url":"https://api.github.com/repos/saleml/pgm-rws/pulls/comments{/number}","comments_url":"https://api.github.com/repos/saleml/pgm-rws/issues/7/comments","statuses_url":"https://api.github.com/repos/saleml/pgm-rws/statuses/a194fd1992497e581ac70f537b4744ea203179ed","head":{"label":"saleml:rim","ref":"rim","sha":"a194fd1992497e581ac70f537b4744ea203179ed","user":{"login":"saleml","id":16039448,"node_id":"MDQ6VXNlcjE2MDM5NDQ4","avatar_url":"https://avatars2.githubusercontent.com/u/16039448?v=4","gravatar_id":"","url":"https://api.github.com/users/saleml","html_url":"https://github.com/saleml","followers_url":"https://api.github.com/users/saleml/followers","following_url":"https://api.github.com/users/saleml/following{/other_user}","gists_url":"https://api.github.com/users/saleml/gists{/gist_id}","starred_url":"https://api.github.com/users/saleml/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saleml/subscriptions","organizations_url":"https://api.github.com/users/saleml/orgs","repos_url":"https://api.github.com/users/saleml/repos","events_url":"https://api.github.com/users/saleml/events{/privacy}","received_events_url":"https://api.github.com/users/saleml/received_events","type":"User","site_admin":false},"repo":{"id":159858417,"node_id":"MDEwOlJlcG9zaXRvcnkxNTk4NTg0MTc=","name":"pgm-rws","full_name":"saleml/pgm-rws","private":false,"owner":{"login":"saleml","id":16039448,"node_id":"MDQ6VXNlcjE2MDM5NDQ4","avatar_url":"https://avatars2.githubusercontent.com/u/16039448?v=4","gravatar_id":"","url":"https://api.github.com/users/saleml","html_url":"https://github.com/saleml","followers_url":"https://api.github.com/users/saleml/followers","following_url":"https://api.github.com/users/saleml/following{/other_user}","gists_url":"https://api.github.com/users/saleml/gists{/gist_id}","starred_url":"https://api.github.com/users/saleml/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saleml/subscriptions","organizations_url":"https://api.github.com/users/saleml/orgs","repos_url":"https://api.github.com/users/saleml/repos","events_url":"https://api.github.com/users/saleml/events{/privacy}","received_events_url":"https://api.github.com/users/saleml/received_events","type":"User","site_admin":false},"html_url":"https://github.com/saleml/pgm-rws","description":"name to be changed later if needed","fork":false,"url":"https://api.github.com/repos/saleml/pgm-rws","forks_url":"https://api.github.com/repos/saleml/pgm-rws/forks","keys_url":"https://api.github.com/repos/saleml/pgm-rws/keys{/key_id}","collaborators_url":"https://api.github.com/repos/saleml/pgm-rws/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/saleml/pgm-rws/teams","hooks_url":"https://api.github.com/repos/saleml/pgm-rws/hooks","issue_events_url":"https://api.github.com/repos/saleml/pgm-rws/issues/events{/number}","events_url":"https://api.github.com/repos/saleml/pgm-rws/events","assignees_url":"https://api.github.com/repos/saleml/pgm-rws/assignees{/user}","branches_url":"https://api.github.com/repos/saleml/pgm-rws/branches{/branch}","tags_url":"https://api.github.com/repos/saleml/pgm-rws/tags","blobs_url":"https://api.github.com/repos/saleml/pgm-rws/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/saleml/pgm-rws/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/saleml/pgm-rws/git/refs{/sha}","trees_url":"https://api.github.com/repos/saleml/pgm-rws/git/trees{/sha}","statuses_url":"https://api.github.com/repos/saleml/pgm-rws/statuses/{sha}","languages_url":"https://api.github.com/repos/saleml/pgm-rws/languages","stargazers_url":"https://api.github.com/repos/saleml/pgm-rws/stargazers","contributors_url":"https://api.github.com/repos/saleml/pgm-rws/contributors","subscribers_url":"https://api.github.com/repos/saleml/pgm-rws/subscribers","subscription_url":"https://api.github.com/repos/saleml/pgm-rws/subscription","commits_url":"https://api.github.com/repos/saleml/pgm-rws/commits{/sha}","git_commits_url":"https://api.github.com/repos/saleml/pgm-rws/git/commits{/sha}","comments_url":"https://api.github.com/repos/saleml/pgm-rws/comments{/number}","issue_comment_url":"https://api.github.com/repos/saleml/pgm-rws/issues/comments{/number}","contents_url":"https://api.github.com/repos/saleml/pgm-rws/contents/{+path}","compare_url":"https://api.github.com/repos/saleml/pgm-rws/compare/{base}...{head}","merges_url":"https://api.github.com/repos/saleml/pgm-rws/merges","archive_url":"https://api.github.com/repos/saleml/pgm-rws/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/saleml/pgm-rws/downloads","issues_url":"https://api.github.com/repos/saleml/pgm-rws/issues{/number}","pulls_url":"https://api.github.com/repos/saleml/pgm-rws/pulls{/number}","milestones_url":"https://api.github.com/repos/saleml/pgm-rws/milestones{/number}","notifications_url":"https://api.github.com/repos/saleml/pgm-rws/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/saleml/pgm-rws/labels{/name}","releases_url":"https://api.github.com/repos/saleml/pgm-rws/releases{/id}","deployments_url":"https://api.github.com/repos/saleml/pgm-rws/deployments","created_at":"2018-11-30T17:41:27Z","updated_at":"2018-12-04T23:36:09Z","pushed_at":"2018-12-05T00:02:07Z","git_url":"git://github.com/saleml/pgm-rws.git","ssh_url":"git@github.com:saleml/pgm-rws.git","clone_url":"https://github.com/saleml/pgm-rws.git","svn_url":"https://github.com/saleml/pgm-rws","homepage":null,"size":43,"stargazers_count":0,"watchers_count":0,"language":"Jupyter Notebook","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":3,"license":null,"forks":0,"open_issues":3,"watchers":0,"default_branch":"master"}},"base":{"label":"saleml:master","ref":"master","sha":"feb1b71579849cffca34100419a4d18dbed688c9","user":{"login":"saleml","id":16039448,"node_id":"MDQ6VXNlcjE2MDM5NDQ4","avatar_url":"https://avatars2.githubusercontent.com/u/16039448?v=4","gravatar_id":"","url":"https://api.github.com/users/saleml","html_url":"https://github.com/saleml","followers_url":"https://api.github.com/users/saleml/followers","following_url":"https://api.github.com/users/saleml/following{/other_user}","gists_url":"https://api.github.com/users/saleml/gists{/gist_id}","starred_url":"https://api.github.com/users/saleml/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saleml/subscriptions","organizations_url":"https://api.github.com/users/saleml/orgs","repos_url":"https://api.github.com/users/saleml/repos","events_url":"https://api.github.com/users/saleml/events{/privacy}","received_events_url":"https://api.github.com/users/saleml/received_events","type":"User","site_admin":false},"repo":{"id":159858417,"node_id":"MDEwOlJlcG9zaXRvcnkxNTk4NTg0MTc=","name":"pgm-rws","full_name":"saleml/pgm-rws","private":false,"owner":{"login":"saleml","id":16039448,"node_id":"MDQ6VXNlcjE2MDM5NDQ4","avatar_url":"https://avatars2.githubusercontent.com/u/16039448?v=4","gravatar_id":"","url":"https://api.github.com/users/saleml","html_url":"https://github.com/saleml","followers_url":"https://api.github.com/users/saleml/followers","following_url":"https://api.github.com/users/saleml/following{/other_user}","gists_url":"https://api.github.com/users/saleml/gists{/gist_id}","starred_url":"https://api.github.com/users/saleml/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saleml/subscriptions","organizations_url":"https://api.github.com/users/saleml/orgs","repos_url":"https://api.github.com/users/saleml/repos","events_url":"https://api.github.com/users/saleml/events{/privacy}","received_events_url":"https://api.github.com/users/saleml/received_events","type":"User","site_admin":false},"html_url":"https://github.com/saleml/pgm-rws","description":"name to be changed later if needed","fork":false,"url":"https://api.github.com/repos/saleml/pgm-rws","forks_url":"https://api.github.com/repos/saleml/pgm-rws/forks","keys_url":"https://api.github.com/repos/saleml/pgm-rws/keys{/key_id}","collaborators_url":"https://api.github.com/repos/saleml/pgm-rws/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/saleml/pgm-rws/teams","hooks_url":"https://api.github.com/repos/saleml/pgm-rws/hooks","issue_events_url":"https://api.github.com/repos/saleml/pgm-rws/issues/events{/number}","events_url":"https://api.github.com/repos/saleml/pgm-rws/events","assignees_url":"https://api.github.com/repos/saleml/pgm-rws/assignees{/user}","branches_url":"https://api.github.com/repos/saleml/pgm-rws/branches{/branch}","tags_url":"https://api.github.com/repos/saleml/pgm-rws/tags","blobs_url":"https://api.github.com/repos/saleml/pgm-rws/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/saleml/pgm-rws/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/saleml/pgm-rws/git/refs{/sha}","trees_url":"https://api.github.com/repos/saleml/pgm-rws/git/trees{/sha}","statuses_url":"https://api.github.com/repos/saleml/pgm-rws/statuses/{sha}","languages_url":"https://api.github.com/repos/saleml/pgm-rws/languages","stargazers_url":"https://api.github.com/repos/saleml/pgm-rws/stargazers","contributors_url":"https://api.github.com/repos/saleml/pgm-rws/contributors","subscribers_url":"https://api.github.com/repos/saleml/pgm-rws/subscribers","subscription_url":"https://api.github.com/repos/saleml/pgm-rws/subscription","commits_url":"https://api.github.com/repos/saleml/pgm-rws/commits{/sha}","git_commits_url":"https://api.github.com/repos/saleml/pgm-rws/git/commits{/sha}","comments_url":"https://api.github.com/repos/saleml/pgm-rws/comments{/number}","issue_comment_url":"https://api.github.com/repos/saleml/pgm-rws/issues/comments{/number}","contents_url":"https://api.github.com/repos/saleml/pgm-rws/contents/{+path}","compare_url":"https://api.github.com/repos/saleml/pgm-rws/compare/{base}...{head}","merges_url":"https://api.github.com/repos/saleml/pgm-rws/merges","archive_url":"https://api.github.com/repos/saleml/pgm-rws/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/saleml/pgm-rws/downloads","issues_url":"https://api.github.com/repos/saleml/pgm-rws/issues{/number}","pulls_url":"https://api.github.com/repos/saleml/pgm-rws/pulls{/number}","milestones_url":"https://api.github.com/repos/saleml/pgm-rws/milestones{/number}","notifications_url":"https://api.github.com/repos/saleml/pgm-rws/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/saleml/pgm-rws/labels{/name}","releases_url":"https://api.github.com/repos/saleml/pgm-rws/releases{/id}","deployments_url":"https://api.github.com/repos/saleml/pgm-rws/deployments","created_at":"2018-11-30T17:41:27Z","updated_at":"2018-12-04T23:36:09Z","pushed_at":"2018-12-05T00:02:07Z","git_url":"git://github.com/saleml/pgm-rws.git","ssh_url":"git@github.com:saleml/pgm-rws.git","clone_url":"https://github.com/saleml/pgm-rws.git","svn_url":"https://github.com/saleml/pgm-rws","homepage":null,"size":43,"stargazers_count":0,"watchers_count":0,"language":"Jupyter Notebook","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":3,"license":null,"forks":0,"open_issues":3,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/saleml/pgm-rws/pulls/7"},"html":{"href":"https://github.com/saleml/pgm-rws/pull/7"},"issue":{"href":"https://api.github.com/repos/saleml/pgm-rws/issues/7"},"comments":{"href":"https://api.github.com/repos/saleml/pgm-rws/issues/7/comments"},"review_comments":{"href":"https://api.github.com/repos/saleml/pgm-rws/pulls/7/comments"},"review_comment":{"href":"https://api.github.com/repos/saleml/pgm-rws/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/saleml/pgm-rws/pulls/7/commits"},"statuses":{"href":"https://api.github.com/repos/saleml/pgm-rws/statuses/a194fd1992497e581ac70f537b4744ea203179ed"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"saleml"}}