{"action":"created","comment":{"url":"https://api.github.com/repos/GPflow/GPflow/pulls/comments/155511991","pull_request_review_id":81841389,"id":155511991,"diff_hunk":"@@ -107,11 +110,13 @@ def _build_likelihood(self):\n         Construct a tensorflow function to compute the bound on the marginal\n         likelihood.\n         \"\"\"\n-        num_inducing = tf.shape(self.Z)[0]\n-        psi0 = tf.reduce_sum(self.kern.eKdiag(self.X_mean, self.X_var), 0)\n-        psi1 = self.kern.eKxz(self.Z, self.X_mean, self.X_var)\n-        psi2 = tf.reduce_sum(self.kern.eKzxKxz(self.Z, self.X_mean, self.X_var), 0)\n-        Kuu = self.kern.K(self.Z) + tf.eye(num_inducing, dtype=settings.tf_float) * settings.numerics.jitter_level\n+        pX = DiagonalGaussian(self.X_mean, self.X_var)\n+\n+        num_inducing = tf.shape(self.feature.Z)[0]\n+        psi0 = tf.reduce_sum(expectation(pX, self.kern), 0)\n+        psi1 = expectation(pX, (self.kern, self.feature))\n+        psi2 = tf.reduce_sum(expectation(pX, (self.kern, self.feature), (self.kern, self.feature)), 0)","path":"gpflow/models/gplvm.py","position":56,"original_position":56,"commit_id":"8707311feeccfeec8e1996bf14a2e6d0a1fce7aa","original_commit_id":"8707311feeccfeec8e1996bf14a2e6d0a1fce7aa","user":{"login":"st--","id":5763727,"avatar_url":"https://avatars0.githubusercontent.com/u/5763727?v=4","gravatar_id":"","url":"https://api.github.com/users/st--","html_url":"https://github.com/st--","followers_url":"https://api.github.com/users/st--/followers","following_url":"https://api.github.com/users/st--/following{/other_user}","gists_url":"https://api.github.com/users/st--/gists{/gist_id}","starred_url":"https://api.github.com/users/st--/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/st--/subscriptions","organizations_url":"https://api.github.com/users/st--/orgs","repos_url":"https://api.github.com/users/st--/repos","events_url":"https://api.github.com/users/st--/events{/privacy}","received_events_url":"https://api.github.com/users/st--/received_events","type":"User","site_admin":false},"body":"If psi0 is a scalar, then why is the sum only over axis=0, not a complete reduction?\r\n(Is it the same difference-in-definition for psi2 as well?)","created_at":"2017-12-07T12:51:36Z","updated_at":"2017-12-07T12:51:36Z","html_url":"https://github.com/GPflow/GPflow/pull/591#discussion_r155511991","pull_request_url":"https://api.github.com/repos/GPflow/GPflow/pulls/591","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/GPflow/GPflow/pulls/comments/155511991"},"html":{"href":"https://github.com/GPflow/GPflow/pull/591#discussion_r155511991"},"pull_request":{"href":"https://api.github.com/repos/GPflow/GPflow/pulls/591"}},"in_reply_to_id":155499139},"pull_request":{"url":"https://api.github.com/repos/GPflow/GPflow/pulls/591","id":156815797,"html_url":"https://github.com/GPflow/GPflow/pull/591","diff_url":"https://github.com/GPflow/GPflow/pull/591.diff","patch_url":"https://github.com/GPflow/GPflow/pull/591.patch","issue_url":"https://api.github.com/repos/GPflow/GPflow/issues/591","number":591,"state":"open","locked":false,"title":"Expectations framework","user":{"login":"vdutor","id":13780846,"avatar_url":"https://avatars2.githubusercontent.com/u/13780846?v=4","gravatar_id":"","url":"https://api.github.com/users/vdutor","html_url":"https://github.com/vdutor","followers_url":"https://api.github.com/users/vdutor/followers","following_url":"https://api.github.com/users/vdutor/following{/other_user}","gists_url":"https://api.github.com/users/vdutor/gists{/gist_id}","starred_url":"https://api.github.com/users/vdutor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vdutor/subscriptions","organizations_url":"https://api.github.com/users/vdutor/orgs","repos_url":"https://api.github.com/users/vdutor/repos","events_url":"https://api.github.com/users/vdutor/events{/privacy}","received_events_url":"https://api.github.com/users/vdutor/received_events","type":"User","site_admin":false},"body":"## Description\r\n\r\nThis PR implements a new framework to deal with expectations over often-used GPFlow objects, such as mean functions and kernels.\r\n\r\nUsing the multiple-dispatch paradigm the framework will select an analytical implementation, if one is available, or fall back to a quadrature implementation if not.\r\n\r\nThe new framework makes the `ekernels` classes obsolete and removes all the quadrature calculation code from the `gpflow.kernels` file. However, none of the original functionality is lost.\r\n\r\nThis PR also includes `mean_function` support for the `uncertain_conditional` function, which relies heavily on the new expectations framework. The BGPLVM implementation is also updated.\r\n\r\n## API\r\n\r\nSome examples should show the usability of the code. Note that any available kernel, mean function or feature can be used, but if an analytical expression is not specified a slower quadrature method will be used. The distribution `pX`, over which we calculate the expectation, can also be chosen.\r\n\r\n```python\r\nfrom gpflow.expectations import expectation\r\n\r\nfeat = InducingPoints(Z)\r\nkern = RBF(...)\r\nmean = Linear(...)\r\npX = Gaussian(mu, cov)\r\n\r\n# Psi statistics\r\neKdiag = expectation(pX, kern)  # psi0\r\neKxz = expectation(pX, (kern, feat))  # psi1\r\neKxzzx = expectation(pX, (kern, feat), (kern, feat))  # psi2\r\n\r\n# kernels and mean functions *NEW*\r\neKxzMx = expectation(pX, (kern, feat), mean)\r\neMxKxz = expectation(pX, mean, (kern, feat))\r\n\r\n# only mean functions *NEW*\r\neMx = expectation(pX, mean)\r\neMx_sq = expectation(pX, mean, mean)\r\n\r\n# different kernels *NEW*\r\n# this occurs when we are calculating Psi2 for Sum kernels\r\neK1xzK2zx = expectation(pX, (kern1, feat), (kern2, feat)) # different kernel\r\n```\r\n","created_at":"2017-12-06T19:17:42Z","updated_at":"2017-12-07T12:51:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4632f7021e176640337b7e514835648b50445d80","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/GPflow/GPflow/pulls/591/commits","review_comments_url":"https://api.github.com/repos/GPflow/GPflow/pulls/591/comments","review_comment_url":"https://api.github.com/repos/GPflow/GPflow/pulls/comments{/number}","comments_url":"https://api.github.com/repos/GPflow/GPflow/issues/591/comments","statuses_url":"https://api.github.com/repos/GPflow/GPflow/statuses/8707311feeccfeec8e1996bf14a2e6d0a1fce7aa","head":{"label":"GPflow:expectations","ref":"expectations","sha":"8707311feeccfeec8e1996bf14a2e6d0a1fce7aa","user":{"login":"GPflow","id":16667412,"avatar_url":"https://avatars2.githubusercontent.com/u/16667412?v=4","gravatar_id":"","url":"https://api.github.com/users/GPflow","html_url":"https://github.com/GPflow","followers_url":"https://api.github.com/users/GPflow/followers","following_url":"https://api.github.com/users/GPflow/following{/other_user}","gists_url":"https://api.github.com/users/GPflow/gists{/gist_id}","starred_url":"https://api.github.com/users/GPflow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GPflow/subscriptions","organizations_url":"https://api.github.com/users/GPflow/orgs","repos_url":"https://api.github.com/users/GPflow/repos","events_url":"https://api.github.com/users/GPflow/events{/privacy}","received_events_url":"https://api.github.com/users/GPflow/received_events","type":"Organization","site_admin":false},"repo":{"id":49643229,"name":"GPflow","full_name":"GPflow/GPflow","owner":{"login":"GPflow","id":16667412,"avatar_url":"https://avatars2.githubusercontent.com/u/16667412?v=4","gravatar_id":"","url":"https://api.github.com/users/GPflow","html_url":"https://github.com/GPflow","followers_url":"https://api.github.com/users/GPflow/followers","following_url":"https://api.github.com/users/GPflow/following{/other_user}","gists_url":"https://api.github.com/users/GPflow/gists{/gist_id}","starred_url":"https://api.github.com/users/GPflow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GPflow/subscriptions","organizations_url":"https://api.github.com/users/GPflow/orgs","repos_url":"https://api.github.com/users/GPflow/repos","events_url":"https://api.github.com/users/GPflow/events{/privacy}","received_events_url":"https://api.github.com/users/GPflow/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/GPflow/GPflow","description":"Gaussian processes in TensorFlow","fork":false,"url":"https://api.github.com/repos/GPflow/GPflow","forks_url":"https://api.github.com/repos/GPflow/GPflow/forks","keys_url":"https://api.github.com/repos/GPflow/GPflow/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GPflow/GPflow/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GPflow/GPflow/teams","hooks_url":"https://api.github.com/repos/GPflow/GPflow/hooks","issue_events_url":"https://api.github.com/repos/GPflow/GPflow/issues/events{/number}","events_url":"https://api.github.com/repos/GPflow/GPflow/events","assignees_url":"https://api.github.com/repos/GPflow/GPflow/assignees{/user}","branches_url":"https://api.github.com/repos/GPflow/GPflow/branches{/branch}","tags_url":"https://api.github.com/repos/GPflow/GPflow/tags","blobs_url":"https://api.github.com/repos/GPflow/GPflow/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GPflow/GPflow/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GPflow/GPflow/git/refs{/sha}","trees_url":"https://api.github.com/repos/GPflow/GPflow/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GPflow/GPflow/statuses/{sha}","languages_url":"https://api.github.com/repos/GPflow/GPflow/languages","stargazers_url":"https://api.github.com/repos/GPflow/GPflow/stargazers","contributors_url":"https://api.github.com/repos/GPflow/GPflow/contributors","subscribers_url":"https://api.github.com/repos/GPflow/GPflow/subscribers","subscription_url":"https://api.github.com/repos/GPflow/GPflow/subscription","commits_url":"https://api.github.com/repos/GPflow/GPflow/commits{/sha}","git_commits_url":"https://api.github.com/repos/GPflow/GPflow/git/commits{/sha}","comments_url":"https://api.github.com/repos/GPflow/GPflow/comments{/number}","issue_comment_url":"https://api.github.com/repos/GPflow/GPflow/issues/comments{/number}","contents_url":"https://api.github.com/repos/GPflow/GPflow/contents/{+path}","compare_url":"https://api.github.com/repos/GPflow/GPflow/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GPflow/GPflow/merges","archive_url":"https://api.github.com/repos/GPflow/GPflow/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GPflow/GPflow/downloads","issues_url":"https://api.github.com/repos/GPflow/GPflow/issues{/number}","pulls_url":"https://api.github.com/repos/GPflow/GPflow/pulls{/number}","milestones_url":"https://api.github.com/repos/GPflow/GPflow/milestones{/number}","notifications_url":"https://api.github.com/repos/GPflow/GPflow/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GPflow/GPflow/labels{/name}","releases_url":"https://api.github.com/repos/GPflow/GPflow/releases{/id}","deployments_url":"https://api.github.com/repos/GPflow/GPflow/deployments","created_at":"2016-01-14T11:29:24Z","updated_at":"2017-12-07T06:22:35Z","pushed_at":"2017-12-07T00:27:30Z","git_url":"git://github.com/GPflow/GPflow.git","ssh_url":"git@github.com:GPflow/GPflow.git","clone_url":"https://github.com/GPflow/GPflow.git","svn_url":"https://github.com/GPflow/GPflow","homepage":"","size":23160,"stargazers_count":523,"watchers_count":523,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":138,"mirror_url":null,"archived":false,"open_issues_count":103,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":138,"open_issues":103,"watchers":523,"default_branch":"master"}},"base":{"label":"GPflow:master","ref":"master","sha":"c3d5f287520d8591a3ba3cf4779e9bc409f54e5d","user":{"login":"GPflow","id":16667412,"avatar_url":"https://avatars2.githubusercontent.com/u/16667412?v=4","gravatar_id":"","url":"https://api.github.com/users/GPflow","html_url":"https://github.com/GPflow","followers_url":"https://api.github.com/users/GPflow/followers","following_url":"https://api.github.com/users/GPflow/following{/other_user}","gists_url":"https://api.github.com/users/GPflow/gists{/gist_id}","starred_url":"https://api.github.com/users/GPflow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GPflow/subscriptions","organizations_url":"https://api.github.com/users/GPflow/orgs","repos_url":"https://api.github.com/users/GPflow/repos","events_url":"https://api.github.com/users/GPflow/events{/privacy}","received_events_url":"https://api.github.com/users/GPflow/received_events","type":"Organization","site_admin":false},"repo":{"id":49643229,"name":"GPflow","full_name":"GPflow/GPflow","owner":{"login":"GPflow","id":16667412,"avatar_url":"https://avatars2.githubusercontent.com/u/16667412?v=4","gravatar_id":"","url":"https://api.github.com/users/GPflow","html_url":"https://github.com/GPflow","followers_url":"https://api.github.com/users/GPflow/followers","following_url":"https://api.github.com/users/GPflow/following{/other_user}","gists_url":"https://api.github.com/users/GPflow/gists{/gist_id}","starred_url":"https://api.github.com/users/GPflow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GPflow/subscriptions","organizations_url":"https://api.github.com/users/GPflow/orgs","repos_url":"https://api.github.com/users/GPflow/repos","events_url":"https://api.github.com/users/GPflow/events{/privacy}","received_events_url":"https://api.github.com/users/GPflow/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/GPflow/GPflow","description":"Gaussian processes in TensorFlow","fork":false,"url":"https://api.github.com/repos/GPflow/GPflow","forks_url":"https://api.github.com/repos/GPflow/GPflow/forks","keys_url":"https://api.github.com/repos/GPflow/GPflow/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GPflow/GPflow/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GPflow/GPflow/teams","hooks_url":"https://api.github.com/repos/GPflow/GPflow/hooks","issue_events_url":"https://api.github.com/repos/GPflow/GPflow/issues/events{/number}","events_url":"https://api.github.com/repos/GPflow/GPflow/events","assignees_url":"https://api.github.com/repos/GPflow/GPflow/assignees{/user}","branches_url":"https://api.github.com/repos/GPflow/GPflow/branches{/branch}","tags_url":"https://api.github.com/repos/GPflow/GPflow/tags","blobs_url":"https://api.github.com/repos/GPflow/GPflow/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GPflow/GPflow/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GPflow/GPflow/git/refs{/sha}","trees_url":"https://api.github.com/repos/GPflow/GPflow/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GPflow/GPflow/statuses/{sha}","languages_url":"https://api.github.com/repos/GPflow/GPflow/languages","stargazers_url":"https://api.github.com/repos/GPflow/GPflow/stargazers","contributors_url":"https://api.github.com/repos/GPflow/GPflow/contributors","subscribers_url":"https://api.github.com/repos/GPflow/GPflow/subscribers","subscription_url":"https://api.github.com/repos/GPflow/GPflow/subscription","commits_url":"https://api.github.com/repos/GPflow/GPflow/commits{/sha}","git_commits_url":"https://api.github.com/repos/GPflow/GPflow/git/commits{/sha}","comments_url":"https://api.github.com/repos/GPflow/GPflow/comments{/number}","issue_comment_url":"https://api.github.com/repos/GPflow/GPflow/issues/comments{/number}","contents_url":"https://api.github.com/repos/GPflow/GPflow/contents/{+path}","compare_url":"https://api.github.com/repos/GPflow/GPflow/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GPflow/GPflow/merges","archive_url":"https://api.github.com/repos/GPflow/GPflow/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GPflow/GPflow/downloads","issues_url":"https://api.github.com/repos/GPflow/GPflow/issues{/number}","pulls_url":"https://api.github.com/repos/GPflow/GPflow/pulls{/number}","milestones_url":"https://api.github.com/repos/GPflow/GPflow/milestones{/number}","notifications_url":"https://api.github.com/repos/GPflow/GPflow/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GPflow/GPflow/labels{/name}","releases_url":"https://api.github.com/repos/GPflow/GPflow/releases{/id}","deployments_url":"https://api.github.com/repos/GPflow/GPflow/deployments","created_at":"2016-01-14T11:29:24Z","updated_at":"2017-12-07T06:22:35Z","pushed_at":"2017-12-07T00:27:30Z","git_url":"git://github.com/GPflow/GPflow.git","ssh_url":"git@github.com:GPflow/GPflow.git","clone_url":"https://github.com/GPflow/GPflow.git","svn_url":"https://github.com/GPflow/GPflow","homepage":"","size":23160,"stargazers_count":523,"watchers_count":523,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":138,"mirror_url":null,"archived":false,"open_issues_count":103,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":138,"open_issues":103,"watchers":523,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/GPflow/GPflow/pulls/591"},"html":{"href":"https://github.com/GPflow/GPflow/pull/591"},"issue":{"href":"https://api.github.com/repos/GPflow/GPflow/issues/591"},"comments":{"href":"https://api.github.com/repos/GPflow/GPflow/issues/591/comments"},"review_comments":{"href":"https://api.github.com/repos/GPflow/GPflow/pulls/591/comments"},"review_comment":{"href":"https://api.github.com/repos/GPflow/GPflow/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/GPflow/GPflow/pulls/591/commits"},"statuses":{"href":"https://api.github.com/repos/GPflow/GPflow/statuses/8707311feeccfeec8e1996bf14a2e6d0a1fce7aa"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"st--"}}