Suppose I have a network f from (x1, x2) ----> f(x1, x2). I want to minimize | df/dx1+2* df/dx2 |, that is, I want to minimize the sum of the derivatives of the output of the network. Does anyone have some idea about this? Thank you.
For example, my network looks like this:
class test(nn.Module):
    def __init__(self):
        super().__init__()
        
        bo_b = False
        self.l1 = nn.Linear(2, 1, bias = bo_b)
        
    def forward(self, state):
        v = self.l1(state)
        return v
tt1 = test()
tt2 = torch.tensor([1, 2])
tt3 = tt1.forward(tt2)

How can I create the criterion ( d tt3/ d x1 + 2*d tt3/ d x2) to minimize? Thanks