Last active
July 10, 2019 02:06
-
-
Save khuangaf/bf09c802d7bfe6b3092a2967d8bba70d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# efficiently compute the aggregation of feature interactions | |
emb_list = [emb_item, pooled_interaction, emb_price_rank, emb_city, emb_last_item, emb_impression_index, emb_star] | |
emb_concat = torch.cat(emb_list, dim=1) | |
sum_squared = torch.pow( torch.sum( emb_concat, dim=1) , 2).unsqueeze(1) | |
squared_sum = torch.sum( torch.pow( emb_concat, 2) , dim=1).unsqueeze(1) | |
second_order = 0.5 * (squared_sum - sum_squared) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment