Propagating a vector backwards

Hello Everyone,

I have a model which has to predict 2 things, and therefore My output is of shape [batch, 2]. My Target too, is of shape [batch, 2]. I calculate the loss as follows -

    dCoordinates = torch.abs(output - coordinates)
    loss = torch.sum(dCoordinates, 1)

Therefore loss is of shape [batch]. How do I propagate this loss backward?




do what you want?

thank you for your reply @gphilip

Suppose the batch size if 4. Then the loss would be something like [0,443, 0,54, 0,21, 0,534]. Each loss would correspond to the respective inputs in the batch. I want to propagate the loss backward to the network for each input.

I do not know how to do that, and I do not know whether what you suggested would do that.
Does it perform the same thing ?