diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/simnet_dygraph_model.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/simnet_dygraph_model.py index 331eeeb3de6810433b75d307f761660f352a1949..bb7e0ca2a0ca7314ff890f9d1204a60842eec3dd 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/simnet_dygraph_model.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/simnet_dygraph_model.py @@ -492,25 +492,16 @@ class BOW(Layer): left_soft = softsign_layer.ops(bow_left) right_soft = softsign_layer.ops(bow_right) - left_bow = self.bow_layer(left_soft) - right_bow = self.bow_layer(right_soft) - cos_sim_layer = CosSimLayer() - pred = cos_sim_layer.ops(left_bow, right_bow) - return left_bow, pred - - # TODO(huihuangzheng): uncomment the following return statements after - # we fix it. - # # matching layer - #if self.task_mode == "pairwise": - # left_bow = self.bow_layer(left_soft) - # right_bow = self.bow_layer(right_soft) - # cos_sim_layer = CosSimLayer() - # pred = cos_sim_layer.ops(left_bow, right_bow) - # return left_bow, pred - #else: - # concat_layer = ConcatLayer(1) - # concat = concat_layer.ops([left_soft, right_soft]) - # concat_fc = self.bow_layer_po(concat) - # pred = self.softmax_layer(concat_fc) - # return left_soft, pred + if self.task_mode == "pairwise": + left_bow = self.bow_layer(left_soft) + right_bow = self.bow_layer(right_soft) + cos_sim_layer = CosSimLayer() + pred = cos_sim_layer.ops(left_bow, right_bow) + return left_bow, pred + else: + concat_layer = ConcatLayer(1) + concat = concat_layer.ops([left_soft, right_soft]) + concat_fc = self.bow_layer_po(concat) + pred = self.softmax_layer(concat_fc) + return left_soft, pred diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_simnet.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_simnet.py index 373e942f6f342a31954d94579508256d42a18ac7..552a6307f33378e7b35f84e048729d22a063c796 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_simnet.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_simnet.py @@ -28,7 +28,7 @@ random.seed(SEED) def create_conf_dict(): conf_dict = {} - conf_dict["task_mode"] = "train" + conf_dict["task_mode"] = "pairwise" conf_dict["net"] = {"emb_dim": 128, "bow_dim": 128, "hidden_dim": 128} conf_dict["loss"] = {"margin": 0.1} return conf_dict