Skip to content

Commit

Permalink
do normalization when use cosine loss
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-gecheng committed Sep 6, 2024
1 parent 0a53697 commit 4426060
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
3 changes: 1 addition & 2 deletions easy_rec/python/model/dssm.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ def build_predict_graph(self):
kernel_regularizer=self._l2_reg,
name='item_dnn/dnn_%d' % (num_item_dnn_layer - 1))

if self._loss_type == LossType.CLASSIFICATION and self._model_config.simi_func == Similarity.COSINE or \
self._model_config.normalization:
if self._model_config.simi_func == Similarity.COSINE:
user_tower_emb = self.norm(user_tower_emb)
item_tower_emb = self.norm(item_tower_emb)
temperature = self._model_config.temperature
Expand Down
3 changes: 1 addition & 2 deletions easy_rec/python/protos/dssm.proto
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,5 @@ message DSSM {
optional string item_id = 9;
required bool ignore_in_batch_neg_sam = 10 [default = false];
// normalize user_tower_embedding and item_tower_embedding
optional bool normalization = 11 [default = false];
optional float temperature = 12 [default = 1.0];
optional float temperature = 11 [default = 1.0];
}

0 comments on commit 4426060

Please sign in to comment.