Hi,
thanks for your answer. But I am not sure how to use the functional interface in my case.
I have a certain trained model; now I want to modify its weights in a certain way (using a function with learnable parameters) and be able to backpropagate to optimize the parameters of the function that modify the weights.
Is there a “clean” way to achieve this? The “dirty” option, if I am not mistaken, would be to call backward() manually; so doing something like
for p in self.parameters():
    p.data = myFunction.forward(p.data)

loss.backward()

for p in self.parameters():
    p.grad.data = myFunction.backward(p.grad.data)

I am not sure this would work though. What do you think?