I use the embedding layer of torch like this:
self.embed_user_GMF = nn.Embedding(user_num, factor_num)
self.embed_item_GMF = nn.Embedding(item_num, factor_num)
with factor_num = 8.
I tried your solution but I got the new error: Given groups=1, weight of size 1 32 2 2, expected input[1, 1, 2042, 2042] to have 32 channels, but got 1 channels instead
My code:
embed_user_MLP = self.embed_user_GMF(user)
embed_item_MLP = self.embed_item_GMF(item)
interaction_matrix = torch.ger(embed_user_MLP.reshape(-1), embed_item_MLP.reshape(-1))
interaction_matrix = interaction_matrix.unsqueeze(0).unsqueeze(1)
output_MCLP = self.MLP_layers(interaction_matrix)