Applying gradient descent to a function using Pytorch

I have 10000 tuples of numbers (x1,x2,y) generated from the equation: y = np.cos(0.583*x1)+np.exp(0.112*x2). I want to use a NN like approach in pytorch to find the 2 parameters i.e. 0.583 and 0.112 using SGD. Here is my code: class NN_test(nn.Module): def __init__(self): super().__init__() self.a = torch.nn.Parameter(torch.tensor(0.7)) self.b = torch.nn.Parameter(torch.tensor(0.02)) def forward(self, x): y =…

Details