{"action":"created","issue":{"url":"https://api.github.com/repos/pytorch/pytorch/issues/1776","repository_url":"https://api.github.com/repos/pytorch/pytorch","labels_url":"https://api.github.com/repos/pytorch/pytorch/issues/1776/labels{/name}","comments_url":"https://api.github.com/repos/pytorch/pytorch/issues/1776/comments","events_url":"https://api.github.com/repos/pytorch/pytorch/issues/1776/events","html_url":"https://github.com/pytorch/pytorch/issues/1776","id":235063112,"number":1776,"title":"Call backward of function in backpropagation","user":{"login":"magzHL","id":29353643,"avatar_url":"https://avatars1.githubusercontent.com/u/29353643?v=4","gravatar_id":"","url":"https://api.github.com/users/magzHL","html_url":"https://github.com/magzHL","followers_url":"https://api.github.com/users/magzHL/followers","following_url":"https://api.github.com/users/magzHL/following{/other_user}","gists_url":"https://api.github.com/users/magzHL/gists{/gist_id}","starred_url":"https://api.github.com/users/magzHL/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/magzHL/subscriptions","organizations_url":"https://api.github.com/users/magzHL/orgs","repos_url":"https://api.github.com/users/magzHL/repos","events_url":"https://api.github.com/users/magzHL/events{/privacy}","received_events_url":"https://api.github.com/users/magzHL/received_events","type":"User","site_admin":false},"labels":[{"id":424131847,"url":"https://api.github.com/repos/pytorch/pytorch/labels/bug","name":"bug","color":"b60205","default":true},{"id":443483881,"url":"https://api.github.com/repos/pytorch/pytorch/labels/low%20priority","name":"low priority","color":"c2e0c6","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":10,"created_at":"2017-06-11T12:41:32Z","updated_at":"2018-03-08T09:23:52Z","closed_at":"2017-09-11T19:42:20Z","author_association":"NONE","body":"Unfortunately the following code snippet leads to an endless loop.\r\nIs there a way to do backward computations on functions inside a backpropagation step? \r\nIt would be nice to have to implement quantized convolutions (e.g. like in https://arxiv.org/pdf/1612.01064.pdf)\r\n```\r\nimport torch\r\n\r\nclass exampleFct(torch.autograd.Function):\r\n    def forward(self, dataIn):\r\n        self.save_for_backward(dataIn)\r\n        print(\"forward...\")\r\n        return dataIn**2\r\n\r\n    def backward(self, grad_output):\r\n        dataIn, = self.saved_tensors\r\n        x_in_back = torch.autograd.Variable(torch.Tensor([2]), requires_grad=True)\r\n        y = x_in_back**2\r\n        print(\"backward...\")\r\n        y.backward(torch.Tensor([1]))\r\n        print(\"unreachable\")\r\n        print(x_in_back.grad.data)\r\n        return grad_output*2*dataIn\r\n\r\n\r\nx = torch.autograd.Variable(torch.Tensor([[3, 4]]), requires_grad=True)\r\nm = exampleFct()\r\nm(x).backward(torch.Tensor([1, 1]))\r\nprint(x.grad.data)\r\n```"},"comment":{"url":"https://api.github.com/repos/pytorch/pytorch/issues/comments/371429729","html_url":"https://github.com/pytorch/pytorch/issues/1776#issuecomment-371429729","issue_url":"https://api.github.com/repos/pytorch/pytorch/issues/1776","id":371429729,"user":{"login":"apaszke","id":4583066,"avatar_url":"https://avatars3.githubusercontent.com/u/4583066?v=4","gravatar_id":"","url":"https://api.github.com/users/apaszke","html_url":"https://github.com/apaszke","followers_url":"https://api.github.com/users/apaszke/followers","following_url":"https://api.github.com/users/apaszke/following{/other_user}","gists_url":"https://api.github.com/users/apaszke/gists{/gist_id}","starred_url":"https://api.github.com/users/apaszke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apaszke/subscriptions","organizations_url":"https://api.github.com/users/apaszke/orgs","repos_url":"https://api.github.com/users/apaszke/repos","events_url":"https://api.github.com/users/apaszke/events{/privacy}","received_events_url":"https://api.github.com/users/apaszke/received_events","type":"User","site_admin":false},"created_at":"2018-03-08T09:23:52Z","updated_at":"2018-03-08T09:23:52Z","author_association":"OWNER","body":"@LMescheder I'm not sure about 0.3, but this should definitely work in master"}}
{"actor":{"display_login":"apaszke"}}