Skip to content

Commit

Permalink
Merge pull request #10 from RUCAIBox/master
Browse files Browse the repository at this point in the history
updates fork
  • Loading branch information
tsotfsk authored Jul 19, 2020
2 parents 6af995d + 1caf594 commit 97a1f4c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 4 additions & 2 deletions model/context_aware_recommender/nfm.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __init__(self, config, dataset):
self.first_order_linear = FMFirstOrderLinear(self.field_dims, self.offsets)
self.embedding = FMEmbedding(self.field_dims, self.offsets, self.embedding_size)
self.fm = BaseFactorizationMachine(reduce_sum=False)
self.mlp_layers = MLPLayers(self.layers, self.dropout, activation='sigmoid')
self.mlp_layers = MLPLayers(size_list, self.dropout, activation='sigmoid')
self.predict_layer = nn.Linear(self.mlp_hidden_size[-1], 1, bias=False)
self.sigmoid = nn.Sigmoid()
self.loss = nn.BCELoss()
Expand Down Expand Up @@ -69,7 +69,9 @@ def forward(self, interaction):
# todo: check (batch) or (batch, 1)
x.append(interaction[field].unsqueeze(1))
x = torch.cat(x, dim=1)
y = self.predict_layer(self.mlp_layers(self.embedding(x)))+self.first_order_linear(x)
emb_x = self.fm(self.embedding(x))

y = self.predict_layer(self.mlp_layers(emb_x))+self.first_order_linear(x)
y = self.sigmoid(y)
return y.squeeze()

Expand Down
5 changes: 5 additions & 0 deletions properties/model/NFM.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[model]

embedding_size=64
mlp_hidden_size=[64, 64, 64]
dropout=0.0

0 comments on commit 97a1f4c

Please sign in to comment.