Hi this is my code for solving quadratic equation. This is working fine but problem is when I try to add one more unknown.
x = torch.nn.Parameter(torch.zeros(1), requires_grad=True) def model(x): b=3 a=2 c=1 global y y = a*x ** 2 + b*x + c return y optimizer = torch.optim.Adam([x], lr=0.1) for i in range(150): a = model(x) loss = (0 - a) ** 2 optimizer.zero_grad() loss.backward() optimizer.step() print(loss)
I am computing loss from x. and my optimizer is optimizing x after every loop. When I change my equation to System of linear equations and I have one more unknown how could I calculate loss and update both unknowns ?
For example equation like this