diff --git a/models/rank/dien/model.py b/models/rank/dien/model.py index 4d1e22783bd1fbea045080b57089be9059c7e9f0..b60f702bac0f6ad46a3986e423d68400a8e19e6a 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)) --------------------------