Created
September 3, 2018 11:33
-
-
Save khuangaf/84eab97783dc7077881f90928278de2a 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
def __init__(self, config): | |
super(NeuMF, self).__init__() | |
#mf part | |
self.embedding_user_mf = torch.nn.Embedding(num_embeddings=self.num_users, embedding_dim=self.latent_dim_mf) | |
self.embedding_item_mf = torch.nn.Embedding(num_embeddings=self.num_items, embedding_dim=self.latent_dim_mf) | |
#mlp part | |
self.embedding_user_mlp = torch.nn.Embedding(num_embeddings=self.num_users, embedding_dim=self.latent_dim_mlp) | |
self.embedding_item_mlp = torch.nn.Embedding(num_embeddings=self.num_items, embedding_dim=self.latent_dim_mlp) | |
self.fc_layers = torch.nn.ModuleList() | |
for idx, (in_size, out_size) in enumerate(zip(config['layers'][:-1], config['layers'][1:])): | |
self.fc_layers.append(torch.nn.Linear(in_size, out_size)) | |
self.logits = torch.nn.Linear(in_features=config['layers'][-1] + config['latent_dim_mf'] , out_features=1) | |
self.sigmoid = torch.nn.Sigmoid() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment