Hello,
I’m having some trouble about c extension in pytorch.
For a hidden layer, In the function class:
class myFunction(torch.autograd.Function):
def __init__(self):
pass
def forward(self, input):
#call c code
#calculate the output
return output
def backward(self, grad_output):
#call c code
#calculate the grad_input
return grad_input
My question is what is the grad_output when the layer comes to be a loss layer, since loss is the final layer. Is it “1”?
And how can I write the backward code.