Closed caiyongqi closed 3 years ago
Thank you for your interest.
We use 0
to pad the sequence and neglect it when we compute the score of each item,
b = self.embedding.weight[1:] # n_nodes x latent_size
scores = torch.matmul(select, b.transpose(1, 0))
The first score in the score list is corresponding to item 1, while its index is 0. So we use targets - 1
to match the target items with the index of scores.
Thank you for your interest. We use
0
to pad the sequence and neglect it when we compute the score of each item,b = self.embedding.weight[1:] # n_nodes x latent_size scores = torch.matmul(select, b.transpose(1, 0))
The first score in the score list is corresponding to item 1, while its index is 0. So we use
targets - 1
to match the target items with the index of scores.
Thank you.
loss = model.loss_function(scores, targets - 1)
Why is the targets minus 1?