Hey!
I’m testing out FlowNet2 implemented in pytorch 2 by fitsumreda 1 and would like to backprop through the network to find the gradients for two input images. The loss im backpropping through is the mse of the flow of the input and constant target flow.
When calling backward() I get the following error:
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)

<ipython-input-21-9531bba54470> in transfer_style(style_imgs, content_imgs, steps, optimizer_type, lr, weights, batch_norm, distance_type, return_intermediate, blur_interv, blur_kernel_size, blur_sigma_sq)
     79                 loss = loss_fn(style,content_param,weights,distance_type)
     80                 loss += flow_loss(content_param)
---> 81                 loss.backward()
     82                 optimizer.step()
     83                 est.tick('Step {}/{}, loss: {}'.format(step+1,steps,loss.data.cpu()[0]))

~/.local/lib/python3.5/site-packages/torch/autograd/variable.py in backward(self, gradient, retain_graph, create_graph, retain_variables)
    165                 Variable.
    166         """
--> 167         torch.autograd.backward(self, gradient, retain_graph, create_graph, retain_variables)
    168 
    169     def register_hook(self, hook):

~/.local/lib/python3.5/site-packages/torch/autograd/__init__.py in backward(variables, grad_variables, retain_graph, create_graph, retain_variables)
     97 
     98     Variable._execution_engine.run_backward(
---> 99         variables, grad_variables, retain_graph)
    100 
    101 

RuntimeError: invalid argument 4: out of range at /pytorch/torch/lib/THC/generic/THCTensor.c:450

How do I interpret this error? Usually it is very easy to understand what went wrong in pytorch thanks to the excellent error messages but as this error is happening in compiled C code I can’t figure out what is wrong.
Worth mentioning is that the forward pass works perfectly and produces correct results. Calling backward() also works if I remove the flownet loss.
If I had more free time I would try to spend time on debugging but this is something im doing as a hobby and free time is limited at the moment.
It might also just be me who is not using the flownet2 implementation correctly.
Im using python 3.5 and pytorch 0.3 installed via pip.
Thanks in advance