I'm writing some homework with python, but there is something wrong with the question, I haven't seen the function before,so i wonder if someone could help me,many thanks!
this is python function
def dF(x):
return 2 * A.T @ (A @ x - np.eye(len(A), dtype=float))
def F(x):
residual = A @ x - np.eye(len(A), dtype=float)
return np.sum(residual ** 2)
def gradient_descent(F, dF, x, steps=100, lr=0.001):
loss = []
for _ in range(steps):
dx = dF(x)
x -= lr * dx
loss.append(F(x))
return x, loss
A = np.array([
[2, 5, 1, 4, 6],
[3, 5, 0, 0, 0],
[1, 1, 0, 3, 8],
[6, 6, 2, 2, 1],
[8, 3, 5, 1, 4],
], dtype=float)
X, loss1 = gradient_descent(F, dF, A * 0, steps=300)
(A @ X).round(2), loss1[-1]
I don't know the meaning of * and @ , it's very hard for me.