Hi Samuel!



 Samuel_Bachorik:

how to write vector like this in python.


Consider the following:
>>> import torch
>>> torch.__version__
'1.9.0'
>>>
>>> # your scalar x = z[0] and y = z[1]
>>> z = torch.nn.Parameter (torch.tensor ([3.0, 7.0]))   # just to make it more interesting than 0.0
>>> equationCoefficients = torch.tensor ([[1.0, 1.0], [1.0, -1.0]])
>>> rhs = torch.tensor ([5.0, 1.0])
>>> lhs = equationCoefficients @ z
>>> lhs
tensor([10., -4.], grad_fn=<MvBackward>)
>>> vectorOfDifferences = lhs - rhs
>>> vectorOfDifferences
tensor([ 5., -5.], grad_fn=<SubBackward0>)
>>> loss = (vectorOfDifferences**2).sum()
>>> loss
tensor(50., grad_fn=<SumBackward0>)

Best.
K. Frank