From b8589509204c28974291d4c4bc8e42b15c987603 Mon Sep 17 00:00:00 2001 From: Qdriving <35327911+Qdriving@users.noreply.github.com> Date: Mon, 28 Sep 2020 15:13:32 +0800 Subject: [PATCH] Update model.py yapf check --- models/rank/dien/model.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/models/rank/dien/model.py b/models/rank/dien/model.py index 74dc97fc..cc487b3b 100755 --- a/models/rank/dien/model.py +++ b/models/rank/dien/model.py @@ -230,7 +230,7 @@ class Model(ModelBase): pad_value) seq_shape = fluid.layers.shape(pos_seq_pad) - if seq_shape[1] < 2: + if (seq_shape[1] == 1): aux_loss = 0 else: test_pos = fluid.layers.reduce_sum( @@ -239,28 +239,26 @@ class Model(ModelBase): 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], :], + * 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], :], + * 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