{"action":"created","issue":{"url":"https://api.github.com/repos/NVIDIA/flownet2-pytorch/issues/29","repository_url":"https://api.github.com/repos/NVIDIA/flownet2-pytorch","labels_url":"https://api.github.com/repos/NVIDIA/flownet2-pytorch/issues/29/labels{/name}","comments_url":"https://api.github.com/repos/NVIDIA/flownet2-pytorch/issues/29/comments","events_url":"https://api.github.com/repos/NVIDIA/flownet2-pytorch/issues/29/events","html_url":"https://github.com/NVIDIA/flownet2-pytorch/issues/29","id":288175413,"number":29,"title":"Fail to adapt to Pytorch Version 0.3","user":{"login":"MatthewD1993","id":14838355,"avatar_url":"https://avatars3.githubusercontent.com/u/14838355?v=4","gravatar_id":"","url":"https://api.github.com/users/MatthewD1993","html_url":"https://github.com/MatthewD1993","followers_url":"https://api.github.com/users/MatthewD1993/followers","following_url":"https://api.github.com/users/MatthewD1993/following{/other_user}","gists_url":"https://api.github.com/users/MatthewD1993/gists{/gist_id}","starred_url":"https://api.github.com/users/MatthewD1993/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MatthewD1993/subscriptions","organizations_url":"https://api.github.com/users/MatthewD1993/orgs","repos_url":"https://api.github.com/users/MatthewD1993/repos","events_url":"https://api.github.com/users/MatthewD1993/events{/privacy}","received_events_url":"https://api.github.com/users/MatthewD1993/received_events","type":"User","site_admin":false},"labels":[{"id":756293928,"url":"https://api.github.com/repos/NVIDIA/flownet2-pytorch/labels/good%20first%20issue","name":"good first issue","color":"7057ff","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2018-01-12T16:33:14Z","updated_at":"2018-02-09T06:57:51Z","closed_at":null,"author_association":"NONE","body":"I am trying to adapt the code to new Pytorch version and higher python version. I modify the code based on  Pytorch source code, especially I modify the customized layers as follows:\r\nfunctions:\r\n`\r\n```\r\nclass ChannelNormFunction(Function):\r\n\r\n    @staticmethod\r\n    def forward(ctx, input1, norm_deg=2):\r\n        # self.save_for_backward(input1)\r\n        ctx.norm_deg = norm_deg\r\n        assert(input1.is_contiguous() == True)\r\n        with torch.cuda.device_of(input1):\r\n            b, _, h, w = input1.size()\r\n            output = input1.new().resize_(b, 1, h, w).zero_()\r\n            ChannelNorm_cuda_forward(input1, output, ctx.norm_deg)\r\n        ctx.save_for_backward(input1, output)\r\n        return output\r\n\r\n    @staticmethod\r\n    def backward(ctx, gradOutput):\r\n        input1, output = ctx.saved_tensors\r\n        with torch.cuda.device_of(input1):\r\n            b, c, h, w = input1.size()\r\n            gradInput1 = input1.new().resize_(b,c,h,w).zero_()\r\n            ChannelNorm_cuda_backward(input1, output, gradOutput, gradInput1, ctx.norm_deg)\r\n\r\n        return gradInput1, None\r\n```\r\n`\r\n\r\nmodules\r\n` \r\n```\r\nclass ChannelNorm(Module):\r\n    def __init__(self, norm_deg=2):\r\n        super(ChannelNorm, self).__init__()\r\n        self.norm_deg = norm_deg\r\n\r\n    def forward(self, input1):\r\n        return ChannelNormFunction.apply(input1, self.norm_deg)\r\n````\r\n\r\nWith other grammatical modifications, I am able to run the code in inference mode. But I fail to train because backpropagation is not working correctly. I met this error:\r\n\r\n>   File \"main.py\", line 434, in <module>\r\n    train_loss, iterations = train(args=args, epoch=epoch, start_iteration=global_iteration, data_loader=train_loader, model=model_and_loss, optimizer=optimizer, logger=train_logger, offset=offset)\r\n  File \"main.py\", line 301, in train\r\n    loss_val.backward()\r\n  File \"/home/cdeng/anaconda3/envs/py27/lib/python2.7/site-packages/torch/autograd/variable.py\", line 167, in backward\r\n    torch.autograd.backward(self, gradient, retain_graph, create_graph, retain_variables)\r\n  File \"/home/cdeng/anaconda3/envs/py27/lib/python2.7/site-packages/torch/autograd/__init__.py\", line 99, in backward\r\n    variables, grad_variables, retain_graph)\r\n  File \"/home/cdeng/anaconda3/envs/py27/lib/python2.7/site-packages/torch/autograd/function.py\", line 91, in apply\r\n    return self._forward_cls.backward(self, *args)\r\n  File \"/home/cdeng/Thesis/flownet2-pytorch/networks/channelnorm_package/functions/channelnorm.py\", line 32, in backward\r\n    ChannelNorm_cuda_backward(input1, output, gradOutput, gradInput1, ctx.norm_deg)\r\n  File \"/home/cdeng/anaconda3/envs/py27/lib/python2.7/site-packages/torch/utils/ffi/__init__.py\", line 180, in safe_call\r\n    result = torch._C._safe_call(*args, **kwargs)\r\nTypeError: initializer for ctype 'struct THCudaTensor *' must be a cdata pointer, not Variable\r\n\r\nCould someone have a look? And help me locate and fix the bug?\r\nGreat thanks!"},"comment":{"url":"https://api.github.com/repos/NVIDIA/flownet2-pytorch/issues/comments/364351897","html_url":"https://github.com/NVIDIA/flownet2-pytorch/issues/29#issuecomment-364351897","issue_url":"https://api.github.com/repos/NVIDIA/flownet2-pytorch/issues/29","id":364351897,"user":{"login":"lfz","id":8953923,"avatar_url":"https://avatars0.githubusercontent.com/u/8953923?v=4","gravatar_id":"","url":"https://api.github.com/users/lfz","html_url":"https://github.com/lfz","followers_url":"https://api.github.com/users/lfz/followers","following_url":"https://api.github.com/users/lfz/following{/other_user}","gists_url":"https://api.github.com/users/lfz/gists{/gist_id}","starred_url":"https://api.github.com/users/lfz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lfz/subscriptions","organizations_url":"https://api.github.com/users/lfz/orgs","repos_url":"https://api.github.com/users/lfz/repos","events_url":"https://api.github.com/users/lfz/events{/privacy}","received_events_url":"https://api.github.com/users/lfz/received_events","type":"User","site_admin":false},"created_at":"2018-02-09T06:57:50Z","updated_at":"2018-02-09T06:57:50Z","author_association":"NONE","body":"https://github.com/pytorch/pytorch/pull/5128#event-1464869248\n\nthe pytorch master has modified the safe_call\n\n2018-02-08 23:31 GMT+08:00 Kai Chen <notifications@github.com>:\n\n> The final output of backward function such as grad_input1 should be a\n> Variable. You can refer to #35\n> <https://github.com/NVIDIA/flownet2-pytorch/pull/35> for details.\n>\n> —\n> You are receiving this because you were mentioned.\n> Reply to this email directly, view it on GitHub\n> <https://github.com/NVIDIA/flownet2-pytorch/issues/29#issuecomment-364147913>,\n> or mute the thread\n> <https://github.com/notifications/unsubscribe-auth/AIigQ5qPzGQ5zVxoIaDULNAkvUvWrySXks5tSxM1gaJpZM4RciSa>\n> .\n>\n\n\n\n-- \n廖方舟\n清华大学医学院\nLiao Fangzhou\nSchool of Medicine\nTsinghua University\nBeijing 100084\nChina\n"}}
{"actor":{"display_login":"lfz"}}