From 5a3bd66930e9ca71a82064f340cf269d60984ac5 Mon Sep 17 00:00:00 2001 From: Qdriving <35327911+Qdriving@users.noreply.github.com> Date: Mon, 28 Sep 2020 14:45:05 +0800 Subject: [PATCH] Update model.py --- models/rank/dien/model.py | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/models/rank/dien/model.py b/models/rank/dien/model.py index b60f702b..ee39ff93 100755 --- a/models/rank/dien/model.py +++ b/models/rank/dien/model.py @@ -234,29 +234,32 @@ class Model(ModelBase): aux_loss = 0 else: test_pos = fluid.layers.reduce_sum( - fluid.layers.reduce_sum( - fluid.layers.log( - fluid.layers.sigmoid( - fluid.layers.reduce_sum( - gru_out_pad[:, start_value:seq_shape[1] - 1, :] * - pos_seq_pad[:, start_value + 1:seq_shape[1], :], - dim=2, - keep_dim=True))), - dim=2), - dim=1, - keep_dim=True) + fluid.layers.reduce_sum( + fluid.layers.log( + fluid.layers.sigmoid( + fluid.layers.reduce_sum( + gru_out_pad[:, start_value:seq_shape[1] - 1, :] + * pos_seq_pad[:, start_value + 1:seq_shape[ + 1], :], + dim=2, + keep_dim=True))), + dim=2), + dim=1, + keep_dim=True) + test_neg = fluid.layers.reduce_sum( - fluid.layers.reduce_sum( fluid.layers.log( fluid.layers.sigmoid( fluid.layers.reduce_sum( - gru_out_pad[:, start_value:seq_shape[1] - 1, :] * - neg_seq_pad[:, start_value + 1:seq_shape[1], :], + gru_out_pad[:, start_value:seq_shape[1] - 1, :] + * neg_seq_pad[:, start_value + 1:seq_shape[ + 1], :], dim=2, keep_dim=True))), dim=2), dim=1, keep_dim=True) + aux_loss = fluid.layers.mean(test_neg + test_pos) # ------------------------- Interest Evolving Layer (GRU with attentional input (AIGRU)) -------------------------- -- GitLab