From a3ddeec0336a5cffec1c5b1e04240248bb195a4c Mon Sep 17 00:00:00 2001 From: xjqbest <173596896@qq.com> Date: Fri, 29 May 2020 10:34:01 +0800 Subject: [PATCH] fix --- core/reader.py | 6 ++++-- core/trainers/single_infer.py | 12 ++++++------ core/trainers/single_trainer.py | 6 +++--- core/utils/dataset_instance.py | 4 ++-- models/rank/dnn/model.py | 6 +++--- 5 files changed, 18 insertions(+), 16 deletions(-) diff --git a/core/reader.py b/core/reader.py index d410b28a..555ae4ba 100755 --- a/core/reader.py +++ b/core/reader.py @@ -59,10 +59,12 @@ class SlotReader(dg.MultiSlotDataGenerator): def init(self, sparse_slots, dense_slots, padding=0): from operator import mul self.sparse_slots = [] - if sparse_slots.strip() != "#": + if sparse_slots.strip() != "#" and sparse_slots.strip( + ) != "?" and sparse_slots.strip() != "": self.sparse_slots = sparse_slots.strip().split(" ") self.dense_slots = [] - if dense_slots.strip() != "#": + if dense_slots.strip() != "#" and dense_slots.strip( + ) != "?" and dense_slots.strip() != "": self.dense_slots = dense_slots.strip().split(" ") self.dense_slots_shape = [ reduce(mul, diff --git a/core/trainers/single_infer.py b/core/trainers/single_infer.py index 7da93bd8..873ff010 100755 --- a/core/trainers/single_infer.py +++ b/core/trainers/single_infer.py @@ -78,14 +78,14 @@ class SingleInfer(TranspileTrainer): pipe_cmd = "python {} {} {} {}".format(reader, reader_class, "TRAIN", self._config_yaml) else: - if sparse_slots is None: - sparse_slots = "#" - if dense_slots is None: - dense_slots = "#" + if sparse_slots == "": + sparse_slots = "?" + if dense_slots == "": + dense_slots = "?" padding = envs.get_global_env(name + "padding", 0) pipe_cmd = "python {} {} {} {} {} {} {} {}".format( reader, "slot", "slot", self._config_yaml, "fake", \ - sparse_slots.replace(" ", "#"), dense_slots.replace(" ", "#"), str(padding)) + sparse_slots.replace(" ", "?"), dense_slots.replace(" ", "?"), str(padding)) dataset = fluid.DatasetFactory().create_dataset() dataset.set_batch_size(envs.get_global_env(name + "batch_size")) @@ -290,7 +290,7 @@ class SingleInfer(TranspileTrainer): def load(self, is_fleet=False): name = "runner." + self._runner_name + "." - dirname = envs.get_global_env("epoch.init_model_path", None) + dirname = envs.get_global_env(name + "init_model_path", None) if dirname is None or dirname == "": return print("single_infer going to load ", dirname) diff --git a/core/trainers/single_trainer.py b/core/trainers/single_trainer.py index 26462552..56741af5 100755 --- a/core/trainers/single_trainer.py +++ b/core/trainers/single_trainer.py @@ -73,13 +73,13 @@ class SingleTrainer(TranspileTrainer): "TRAIN", self._config_yaml) else: if sparse_slots == "": - sparse_slots = "#" + sparse_slots = "?" if dense_slots == "": - dense_slots = "#" + dense_slots = "?" padding = envs.get_global_env(name + "padding", 0) pipe_cmd = "python {} {} {} {} {} {} {} {}".format( reader, "slot", "slot", self._config_yaml, "fake", \ - sparse_slots.replace(" ", "#"), dense_slots.replace(" ", "#"), str(padding)) + sparse_slots.replace(" ", "?"), dense_slots.replace(" ", "?"), str(padding)) dataset = fluid.DatasetFactory().create_dataset() dataset.set_batch_size(envs.get_global_env(name + "batch_size")) diff --git a/core/utils/dataset_instance.py b/core/utils/dataset_instance.py index 2e6082dc..3f0a3a48 100755 --- a/core/utils/dataset_instance.py +++ b/core/utils/dataset_instance.py @@ -32,8 +32,8 @@ elif sys.argv[2].upper() == "EVALUATE": else: reader_name = "SlotReader" namespace = sys.argv[4] - sparse_slots = sys.argv[5].replace("#", " ") - dense_slots = sys.argv[6].replace("#", " ") + sparse_slots = sys.argv[5].replace("?", " ") + dense_slots = sys.argv[6].replace("?", " ") padding = int(sys.argv[7]) yaml_abs_path = sys.argv[3] diff --git a/models/rank/dnn/model.py b/models/rank/dnn/model.py index d417d4d9..f4425e3d 100755 --- a/models/rank/dnn/model.py +++ b/models/rank/dnn/model.py @@ -36,7 +36,7 @@ class Model(ModelBase): def net(self, input, is_infer=False): self.sparse_inputs = self._sparse_data_var[1:] - self.dense_input = self._dense_data_var[0] + self.dense_input = [] #self._dense_data_var[0] self.label_input = self._sparse_data_var[0] def embedding_layer(input): @@ -52,8 +52,8 @@ class Model(ModelBase): return emb_sum sparse_embed_seq = list(map(embedding_layer, self.sparse_inputs)) - concated = fluid.layers.concat( - sparse_embed_seq + [self.dense_input], axis=1) + concated = fluid.layers.concat(sparse_embed_seq, axis=1) + #sparse_embed_seq + [self.dense_input], axis=1) fcs = [concated] hidden_layers = envs.get_global_env("hyper_parameters.fc_sizes") -- GitLab