From 0ededf12c9947d7316768061745929c4a0f7dc13 Mon Sep 17 00:00:00 2001 From: Qdriving <35327911+Qdriving@users.noreply.github.com> Date: Mon, 28 Sep 2020 14:29:53 +0800 Subject: [PATCH] Length of hist_item_seq[batch_size][i] error The condition that max length of hist_item_seq[batch_size][i] == 1 is not covered. But it is happened when I run the baseline of dien model. --- models/rank/dien/model.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/models/rank/dien/model.py b/models/rank/dien/model.py index 4d1e2278..b60f702b 100755 --- a/models/rank/dien/model.py +++ b/models/rank/dien/model.py @@ -229,7 +229,11 @@ class Model(ModelBase): neg_seq_pad, _ = fluid.layers.sequence_pad(neg_reshape_hist_item_emb, pad_value) seq_shape = fluid.layers.shape(pos_seq_pad) - test_pos = fluid.layers.reduce_sum( + + if(seq_shape[1] < 2): + aux_loss = 0 + else: + test_pos = fluid.layers.reduce_sum( fluid.layers.reduce_sum( fluid.layers.log( fluid.layers.sigmoid( @@ -241,7 +245,7 @@ class Model(ModelBase): dim=2), dim=1, keep_dim=True) - test_neg = fluid.layers.reduce_sum( + test_neg = fluid.layers.reduce_sum( fluid.layers.reduce_sum( fluid.layers.log( fluid.layers.sigmoid( @@ -253,7 +257,7 @@ class Model(ModelBase): dim=2), dim=1, keep_dim=True) - aux_loss = fluid.layers.mean(test_neg + test_pos) + aux_loss = fluid.layers.mean(test_neg + test_pos) # ------------------------- Interest Evolving Layer (GRU with attentional input (AIGRU)) -------------------------- -- GitLab