Backward with two networks

I have two net works A and B, the output is out = A(x1) + B(x2), it is a matrix. Now I want use out.backward(matrixj). I know there should be a maxtrxj, which has the same size with out, but I’m not sure if it is ok I just use a matrix with all element is 1.

It’s possible to do the backward with two networks. You have to create a loss function before you can do that though. Once you’ve calculated the loss you can do my_loss.backward()

See the pytorch examples for how it’s done with one network. It’s pretty much the same with two networks :slight_smile:

Hi, thank you for your reply, but I think you maybe misunderstand me, I know we can use loss function for the back propagation, but what I’m doing now is use the matrix for the back propagation, I want use some thing like Jacobi matrix, I want to know if I can set all element is 1 in matrixj

Okay I see. Never done that myself. Good luck :slight_smile: