great material thanks
but
where is manual simple code in your final big code file
Create random initial latent matrices
U = np.random.uniform(-1, 1, size=(num_users, K))
V = np.random.uniform(-1, 1, size=(num_items, K))
N = num_users * num_items
Training
for curr_epoch in range(num_epochs):
# Reconstruct R_hat from latent factor matrices (linear operation)
R_hat = U @ V.T # @ means matrix multiplcation, .T means transpose
# Calc MSE loss of this reconstruction
loss = np.square(R - R_hat).mean()
# Calc partial derivative of MSE with respect to U and V
U_grad = -2./N * (R - R_hat)@v
V_grad = -2./N * (R - R_hat)@U
# Update U and V using their respective gradients and learning rate
U -= lr * U_grad
V -= lr * V_grad
great material thanks
but
where is manual simple code in your final big code file
Create random initial latent matrices
U = np.random.uniform(-1, 1, size=(num_users, K))
V = np.random.uniform(-1, 1, size=(num_items, K))
N = num_users * num_items
Training
for curr_epoch in range(num_epochs):
# Reconstruct R_hat from latent factor matrices (linear operation)
R_hat = U @ V.T # @ means matrix multiplcation, .T means transpose
# Calc MSE loss of this reconstruction
loss = np.square(R - R_hat).mean()
# Calc partial derivative of MSE with respect to U and V
U_grad = -2./N * (R - R_hat)@v
V_grad = -2./N * (R - R_hat)@U
# Update U and V using their respective gradients and learning rate
U -= lr * U_grad
V -= lr * V_grad