I am new to pytorch (from torch) and I am trying to implement a multitask learning framework. Essentially, I have the following:
err1 = net1(input1)
err2 = net2(input2)

where net2 takes inputs from different layers of net1 and err1 and err2 are inputs to two different loss functions. I am confused as to how to perform backward pass here. I know that one can use torch.autograd.backward(variables, grads), but what are the variables and grads ? Are the variables [err1,err2] ? If so, how do I get the grads ? or Am I completely on the wrong path ? Any help would be appreciated.