Hello,
I’m trying to replace the Excel optimization with PyTorch. I extracted the dataset (attached here), and tried to create the whole process. But I don’t know how can I optimize it (minimize the loss).
if __name__ == '__main__':
df = pd.read_csv("data.csv", sep=";", header=None).fillna(0.)
inputs = torch.tensor(df.values, dtype=torch.float32)
# Create the User Embeddings
u_weight = torch.zeros([df.shape[0], 5], dtype=torch.float32).uniform_()
# Create the Movie Embeddings
i_weight = torch.zeros([df.shape[1], 5], dtype=torch.float32).uniform_()
# Weight Matrix
dot = (u_weight @ i_weight.T)
# Calculate the Loss (RMSE)
for i in range(0, 5):
print("Epoch ", i)
loss = torch.sqrt(torch.mean((inputs - dot)**2))
print("Loss = ", loss)
# TODO: How to optimize here?