Hi,

I have a model and i need to train it with a self calculated gradient instead of a loss function but how do i backpropagate this gradient? I have a model and optimizer:

model = Model()

now i can calculate the output and the gradient:

out = model(input)

And normally i use now loss.backward() and optimizer.step() when i have a loss function but how can i backpropagate now with the calculated gradient?

Is using the following correct?: