Closed thinkall closed 3 years ago
Thanks to point out this mistake. I changed the code days ago but I haven't fully tested it.
However, I would prefer this as it should be faster.
--- a/src/model/DKN/__init__.py
+++ b/src/model/DKN/__init__.py
@@ -97,7 +97,7 @@ class DKN(torch.nn.Module):
"""
# candidate_size, len(window_sizes) * num_filters
user_vector = self.attention(candidate_news_vector,
- clicked_news_vector.unsqueeze(dim=0))
+ clicked_news_vector.expand(candidate_news_vector.size(0), -1, -1))
# candidate_size
click_probability = self.click_predictor(candidate_news_vector,
user_vector)
Ah, yes, thanks.
Already merged. Thanks again~
The candidate_news_vector passed to attention class should be [batch_size, len(window_sizes) num_filters], but the current version has dimension [num_candidate_news, len(window_sizes) num_filters]. In prediction mode, the batch_size should be 1 as clicked_news_vector.unsqueeze(dim=0) has done.