{"action":"created","comment":{"url":"https://api.github.com/repos/tensorflow/haskell/pulls/comments/85443322","pull_request_review_id":6160725,"id":85443322,"diff_hunk":"@@ -73,13 +73,12 @@ sigmoidCrossEntropyWithLogits\n   :: (OneOf '[Float, Double] a, TensorType a, Num a)\n      => Tensor Value a          -- ^ __logits__\n      -> Tensor Value a          -- ^ __targets__\n-     -> Build (Tensor Value a)\n+     -> Tensor Value a\n sigmoidCrossEntropyWithLogits logits targets = do\n     let zeros = zerosLike logits\n         cond = logits `greaterEqual` zeros\n         relu_logits = select cond logits zeros\n         neg_abs_logits = select cond (-logits) logits\n-    withNameScope \"logistic_loss\" $ do","path":"tensorflow-nn/src/TensorFlow/NN.hs","position":null,"original_position":11,"commit_id":"73dba5bcbf77eab4d60bdea27bf48d2f9e91cae9","original_commit_id":"541b8da20ed8f3a2358700b3aa9bd6df3e32ce81","user":{"login":"fkm3","id":2624824,"avatar_url":"https://avatars.githubusercontent.com/u/2624824?v=3","gravatar_id":"","url":"https://api.github.com/users/fkm3","html_url":"https://github.com/fkm3","followers_url":"https://api.github.com/users/fkm3/followers","following_url":"https://api.github.com/users/fkm3/following{/other_user}","gists_url":"https://api.github.com/users/fkm3/gists{/gist_id}","starred_url":"https://api.github.com/users/fkm3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fkm3/subscriptions","organizations_url":"https://api.github.com/users/fkm3/orgs","repos_url":"https://api.github.com/users/fkm3/repos","events_url":"https://api.github.com/users/fkm3/events{/privacy}","received_events_url":"https://api.github.com/users/fkm3/received_events","type":"User","site_admin":false},"body":"Here is a version that works with `Build`:\r\n\r\n```haskell\r\nsigmoidCrossEntropyWithLogits\r\n  :: (OneOf '[Float, Double] a, TensorType a, Num a)\r\n     => Tensor Value a          -- ^ __logits__\r\n     -> Tensor Value a          -- ^ __targets__\r\n     -> Build (Tensor Value a)\r\nsigmoidCrossEntropyWithLogits logits targets = do\r\n    logits' <- render logits\r\n    targets' <- render targets\r\n    let zeros = zerosLike logits'\r\n        cond = logits' `greaterEqual` zeros\r\n        relu_logits = select cond logits' zeros\r\n        neg_abs_logits = select cond (-logits') logits'\r\n    withNameScope \"logistic_loss\" $ do\r\n        left  <- render $ relu_logits - logits' * targets'\r\n        right <- render $ log (1 + exp neg_abs_logits)\r\n        withNameScope \"sigmoid_add\" $ render $ left `add` right\r\n```\r\n\r\n(the only difference is that it renders the input tensors outside of the scope)\r\n\r\nThis is one of the confusing aspects of how we are handling name scopes right now. The `logits` here is rendered inside the \"logistic_loss\" name scope and the one in the test (`vLogits` in `TF.gradients tfLoss [vLogits]`) is rendered outside of it, so you end up with two distinct tensors. The one in the test is never used, so the gradient w.r.t. it is always zero.\r\n\r\n@blackgnezdo probably didn't run into this because we usually only calculate for the gradient w.r.t. a variable and variable creation is done inside `Build`.","created_at":"2016-10-27T22:46:51Z","updated_at":"2016-10-27T22:46:52Z","html_url":"https://github.com/tensorflow/haskell/pull/11#discussion_r85443322","pull_request_url":"https://api.github.com/repos/tensorflow/haskell/pulls/11","_links":{"self":{"href":"https://api.github.com/repos/tensorflow/haskell/pulls/comments/85443322"},"html":{"href":"https://github.com/tensorflow/haskell/pull/11#discussion_r85443322"},"pull_request":{"href":"https://api.github.com/repos/tensorflow/haskell/pulls/11"}}},"pull_request":{"url":"https://api.github.com/repos/tensorflow/haskell/pulls/11","id":91119776,"html_url":"https://github.com/tensorflow/haskell/pull/11","diff_url":"https://github.com/tensorflow/haskell/pull/11.diff","patch_url":"https://github.com/tensorflow/haskell/pull/11.patch","issue_url":"https://api.github.com/repos/tensorflow/haskell/issues/11","number":11,"state":"open","locked":false,"title":"Starting NN library","user":{"login":"silky","id":129525,"avatar_url":"https://avatars.githubusercontent.com/u/129525?v=3","gravatar_id":"","url":"https://api.github.com/users/silky","html_url":"https://github.com/silky","followers_url":"https://api.github.com/users/silky/followers","following_url":"https://api.github.com/users/silky/following{/other_user}","gists_url":"https://api.github.com/users/silky/gists{/gist_id}","starred_url":"https://api.github.com/users/silky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/silky/subscriptions","organizations_url":"https://api.github.com/users/silky/orgs","repos_url":"https://api.github.com/users/silky/repos","events_url":"https://api.github.com/users/silky/events{/privacy}","received_events_url":"https://api.github.com/users/silky/received_events","type":"User","site_admin":false},"body":"- Added \"sigmoidCrossEntropyWithLogits\"\r\n- Ported across a single test\r\n\r\nfixes #10 (well, it adds a single function, and it's a place to start.)\r\n\r\nthe test could probably be cleaned up quite a bit; happy to do that later on, just wanted to get this up.\r\n","created_at":"2016-10-27T01:44:14Z","updated_at":"2016-10-27T22:46:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"096da01bc0cb14b5b8bfe194f75a15da0d34586c","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/tensorflow/haskell/pulls/11/commits","review_comments_url":"https://api.github.com/repos/tensorflow/haskell/pulls/11/comments","review_comment_url":"https://api.github.com/repos/tensorflow/haskell/pulls/comments{/number}","comments_url":"https://api.github.com/repos/tensorflow/haskell/issues/11/comments","statuses_url":"https://api.github.com/repos/tensorflow/haskell/statuses/73dba5bcbf77eab4d60bdea27bf48d2f9e91cae9","head":{"label":"silky:nn-lib","ref":"nn-lib","sha":"73dba5bcbf77eab4d60bdea27bf48d2f9e91cae9","user":{"login":"silky","id":129525,"avatar_url":"https://avatars.githubusercontent.com/u/129525?v=3","gravatar_id":"","url":"https://api.github.com/users/silky","html_url":"https://github.com/silky","followers_url":"https://api.github.com/users/silky/followers","following_url":"https://api.github.com/users/silky/following{/other_user}","gists_url":"https://api.github.com/users/silky/gists{/gist_id}","starred_url":"https://api.github.com/users/silky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/silky/subscriptions","organizations_url":"https://api.github.com/users/silky/orgs","repos_url":"https://api.github.com/users/silky/repos","events_url":"https://api.github.com/users/silky/events{/privacy}","received_events_url":"https://api.github.com/users/silky/received_events","type":"User","site_admin":false},"repo":{"id":71838567,"name":"haskell","full_name":"silky/haskell","owner":{"login":"silky","id":129525,"avatar_url":"https://avatars.githubusercontent.com/u/129525?v=3","gravatar_id":"","url":"https://api.github.com/users/silky","html_url":"https://github.com/silky","followers_url":"https://api.github.com/users/silky/followers","following_url":"https://api.github.com/users/silky/following{/other_user}","gists_url":"https://api.github.com/users/silky/gists{/gist_id}","starred_url":"https://api.github.com/users/silky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/silky/subscriptions","organizations_url":"https://api.github.com/users/silky/orgs","repos_url":"https://api.github.com/users/silky/repos","events_url":"https://api.github.com/users/silky/events{/privacy}","received_events_url":"https://api.github.com/users/silky/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/silky/haskell","description":null,"fork":true,"url":"https://api.github.com/repos/silky/haskell","forks_url":"https://api.github.com/repos/silky/haskell/forks","keys_url":"https://api.github.com/repos/silky/haskell/keys{/key_id}","collaborators_url":"https://api.github.com/repos/silky/haskell/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/silky/haskell/teams","hooks_url":"https://api.github.com/repos/silky/haskell/hooks","issue_events_url":"https://api.github.com/repos/silky/haskell/issues/events{/number}","events_url":"https://api.github.com/repos/silky/haskell/events","assignees_url":"https://api.github.com/repos/silky/haskell/assignees{/user}","branches_url":"https://api.github.com/repos/silky/haskell/branches{/branch}","tags_url":"https://api.github.com/repos/silky/haskell/tags","blobs_url":"https://api.github.com/repos/silky/haskell/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/silky/haskell/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/silky/haskell/git/refs{/sha}","trees_url":"https://api.github.com/repos/silky/haskell/git/trees{/sha}","statuses_url":"https://api.github.com/repos/silky/haskell/statuses/{sha}","languages_url":"https://api.github.com/repos/silky/haskell/languages","stargazers_url":"https://api.github.com/repos/silky/haskell/stargazers","contributors_url":"https://api.github.com/repos/silky/haskell/contributors","subscribers_url":"https://api.github.com/repos/silky/haskell/subscribers","subscription_url":"https://api.github.com/repos/silky/haskell/subscription","commits_url":"https://api.github.com/repos/silky/haskell/commits{/sha}","git_commits_url":"https://api.github.com/repos/silky/haskell/git/commits{/sha}","comments_url":"https://api.github.com/repos/silky/haskell/comments{/number}","issue_comment_url":"https://api.github.com/repos/silky/haskell/issues/comments{/number}","contents_url":"https://api.github.com/repos/silky/haskell/contents/{+path}","compare_url":"https://api.github.com/repos/silky/haskell/compare/{base}...{head}","merges_url":"https://api.github.com/repos/silky/haskell/merges","archive_url":"https://api.github.com/repos/silky/haskell/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/silky/haskell/downloads","issues_url":"https://api.github.com/repos/silky/haskell/issues{/number}","pulls_url":"https://api.github.com/repos/silky/haskell/pulls{/number}","milestones_url":"https://api.github.com/repos/silky/haskell/milestones{/number}","notifications_url":"https://api.github.com/repos/silky/haskell/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/silky/haskell/labels{/name}","releases_url":"https://api.github.com/repos/silky/haskell/releases{/id}","deployments_url":"https://api.github.com/repos/silky/haskell/deployments","created_at":"2016-10-24T22:50:02Z","updated_at":"2016-10-24T22:50:04Z","pushed_at":"2016-10-27T22:09:51Z","git_url":"git://github.com/silky/haskell.git","ssh_url":"git@github.com:silky/haskell.git","clone_url":"https://github.com/silky/haskell.git","svn_url":"https://github.com/silky/haskell","homepage":null,"size":917,"stargazers_count":0,"watchers_count":0,"language":"Haskell","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"tensorflow:master","ref":"master","sha":"03a3a6d086937cfbc1b11e8741c8425e214499e9","user":{"login":"tensorflow","id":15658638,"avatar_url":"https://avatars.githubusercontent.com/u/15658638?v=3","gravatar_id":"","url":"https://api.github.com/users/tensorflow","html_url":"https://github.com/tensorflow","followers_url":"https://api.github.com/users/tensorflow/followers","following_url":"https://api.github.com/users/tensorflow/following{/other_user}","gists_url":"https://api.github.com/users/tensorflow/gists{/gist_id}","starred_url":"https://api.github.com/users/tensorflow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tensorflow/subscriptions","organizations_url":"https://api.github.com/users/tensorflow/orgs","repos_url":"https://api.github.com/users/tensorflow/repos","events_url":"https://api.github.com/users/tensorflow/events{/privacy}","received_events_url":"https://api.github.com/users/tensorflow/received_events","type":"Organization","site_admin":false},"repo":{"id":71028374,"name":"haskell","full_name":"tensorflow/haskell","owner":{"login":"tensorflow","id":15658638,"avatar_url":"https://avatars.githubusercontent.com/u/15658638?v=3","gravatar_id":"","url":"https://api.github.com/users/tensorflow","html_url":"https://github.com/tensorflow","followers_url":"https://api.github.com/users/tensorflow/followers","following_url":"https://api.github.com/users/tensorflow/following{/other_user}","gists_url":"https://api.github.com/users/tensorflow/gists{/gist_id}","starred_url":"https://api.github.com/users/tensorflow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tensorflow/subscriptions","organizations_url":"https://api.github.com/users/tensorflow/orgs","repos_url":"https://api.github.com/users/tensorflow/repos","events_url":"https://api.github.com/users/tensorflow/events{/privacy}","received_events_url":"https://api.github.com/users/tensorflow/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/tensorflow/haskell","description":"Haskell bindings for TensorFlow","fork":false,"url":"https://api.github.com/repos/tensorflow/haskell","forks_url":"https://api.github.com/repos/tensorflow/haskell/forks","keys_url":"https://api.github.com/repos/tensorflow/haskell/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tensorflow/haskell/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tensorflow/haskell/teams","hooks_url":"https://api.github.com/repos/tensorflow/haskell/hooks","issue_events_url":"https://api.github.com/repos/tensorflow/haskell/issues/events{/number}","events_url":"https://api.github.com/repos/tensorflow/haskell/events","assignees_url":"https://api.github.com/repos/tensorflow/haskell/assignees{/user}","branches_url":"https://api.github.com/repos/tensorflow/haskell/branches{/branch}","tags_url":"https://api.github.com/repos/tensorflow/haskell/tags","blobs_url":"https://api.github.com/repos/tensorflow/haskell/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tensorflow/haskell/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tensorflow/haskell/git/refs{/sha}","trees_url":"https://api.github.com/repos/tensorflow/haskell/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tensorflow/haskell/statuses/{sha}","languages_url":"https://api.github.com/repos/tensorflow/haskell/languages","stargazers_url":"https://api.github.com/repos/tensorflow/haskell/stargazers","contributors_url":"https://api.github.com/repos/tensorflow/haskell/contributors","subscribers_url":"https://api.github.com/repos/tensorflow/haskell/subscribers","subscription_url":"https://api.github.com/repos/tensorflow/haskell/subscription","commits_url":"https://api.github.com/repos/tensorflow/haskell/commits{/sha}","git_commits_url":"https://api.github.com/repos/tensorflow/haskell/git/commits{/sha}","comments_url":"https://api.github.com/repos/tensorflow/haskell/comments{/number}","issue_comment_url":"https://api.github.com/repos/tensorflow/haskell/issues/comments{/number}","contents_url":"https://api.github.com/repos/tensorflow/haskell/contents/{+path}","compare_url":"https://api.github.com/repos/tensorflow/haskell/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tensorflow/haskell/merges","archive_url":"https://api.github.com/repos/tensorflow/haskell/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tensorflow/haskell/downloads","issues_url":"https://api.github.com/repos/tensorflow/haskell/issues{/number}","pulls_url":"https://api.github.com/repos/tensorflow/haskell/pulls{/number}","milestones_url":"https://api.github.com/repos/tensorflow/haskell/milestones{/number}","notifications_url":"https://api.github.com/repos/tensorflow/haskell/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tensorflow/haskell/labels{/name}","releases_url":"https://api.github.com/repos/tensorflow/haskell/releases{/id}","deployments_url":"https://api.github.com/repos/tensorflow/haskell/deployments","created_at":"2016-10-16T03:40:47Z","updated_at":"2016-10-27T19:22:34Z","pushed_at":"2016-10-27T22:09:51Z","git_url":"git://github.com/tensorflow/haskell.git","ssh_url":"git@github.com:tensorflow/haskell.git","clone_url":"https://github.com/tensorflow/haskell.git","svn_url":"https://github.com/tensorflow/haskell","homepage":"https://tensorflow.github.io/haskell/haddock/","size":1080,"stargazers_count":215,"watchers_count":215,"language":"Haskell","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":14,"mirror_url":null,"open_issues_count":4,"forks":14,"open_issues":4,"watchers":215,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tensorflow/haskell/pulls/11"},"html":{"href":"https://github.com/tensorflow/haskell/pull/11"},"issue":{"href":"https://api.github.com/repos/tensorflow/haskell/issues/11"},"comments":{"href":"https://api.github.com/repos/tensorflow/haskell/issues/11/comments"},"review_comments":{"href":"https://api.github.com/repos/tensorflow/haskell/pulls/11/comments"},"review_comment":{"href":"https://api.github.com/repos/tensorflow/haskell/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/tensorflow/haskell/pulls/11/commits"},"statuses":{"href":"https://api.github.com/repos/tensorflow/haskell/statuses/73dba5bcbf77eab4d60bdea27bf48d2f9e91cae9"}}}}
{"actor":{"display_login":"fkm3"}}