提交 af164aa2 编写于 作者: X xujiaqi01

fix

上级 3e50521c
...@@ -37,7 +37,6 @@ class Model(object): ...@@ -37,7 +37,6 @@ class Model(object):
self._fetch_interval = 20 self._fetch_interval = 20
self._namespace = "train.model" self._namespace = "train.model"
self._platform = envs.get_platform() self._platform = envs.get_platform()
self._init_slots()
def _init_slots(self): def _init_slots(self):
sparse_slots = envs.get_global_env("sparse_slots", None, "train.reader") sparse_slots = envs.get_global_env("sparse_slots", None, "train.reader")
......
...@@ -234,7 +234,6 @@ class TranspileTrainer(Trainer): ...@@ -234,7 +234,6 @@ class TranspileTrainer(Trainer):
startup_program = fluid.Program() startup_program = fluid.Program()
with fluid.unique_name.guard(): with fluid.unique_name.guard():
with fluid.program_guard(infer_program, startup_program): with fluid.program_guard(infer_program, startup_program):
self.model._init_slots()
self.model.infer_net() self.model.infer_net()
if self.model._infer_data_loader is None: if self.model._infer_data_loader is None:
......
...@@ -112,6 +112,7 @@ class Model(ModelBase): ...@@ -112,6 +112,7 @@ class Model(ModelBase):
return fluid.layers.reduce_sum(fluid.layers.square(w)) return fluid.layers.reduce_sum(fluid.layers.square(w))
def train_net(self): def train_net(self):
self.model._init_slots()
self.init_network() self.init_network()
self.net_input = self._create_embedding_input() self.net_input = self._create_embedding_input()
...@@ -149,4 +150,5 @@ class Model(ModelBase): ...@@ -149,4 +150,5 @@ class Model(ModelBase):
return optimizer return optimizer
def infer_net(self, parameter_list): def infer_net(self, parameter_list):
self.model._init_slots()
self.deepfm_net() self.deepfm_net()
...@@ -124,6 +124,7 @@ class Model(ModelBase): ...@@ -124,6 +124,7 @@ class Model(ModelBase):
self.predict = fluid.layers.sigmoid(y_first_order + y_second_order + y_dnn) self.predict = fluid.layers.sigmoid(y_first_order + y_second_order + y_dnn)
def train_net(self): def train_net(self):
self.model._init_slots()
self.deepfm_net() self.deepfm_net()
# ------------------------- Cost(logloss) -------------------------- # ------------------------- Cost(logloss) --------------------------
...@@ -149,4 +150,5 @@ class Model(ModelBase): ...@@ -149,4 +150,5 @@ class Model(ModelBase):
return optimizer return optimizer
def infer_net(self, parameter_list): def infer_net(self, parameter_list):
self.model._init_slots()
self.deepfm_net() self.deepfm_net()
...@@ -88,6 +88,7 @@ class Model(ModelBase): ...@@ -88,6 +88,7 @@ class Model(ModelBase):
self._metrics["BATCH_AUC"] = batch_auc self._metrics["BATCH_AUC"] = batch_auc
def train_net(self): def train_net(self):
self.model._init_slots()
self.input() self.input()
self.net() self.net()
self.avg_loss() self.avg_loss()
...@@ -99,5 +100,6 @@ class Model(ModelBase): ...@@ -99,5 +100,6 @@ class Model(ModelBase):
return optimizer return optimizer
def infer_net(self): def infer_net(self):
self.model._init_slots()
self.input() self.input()
self.net() self.net()
...@@ -57,6 +57,7 @@ class Model(ModelBase): ...@@ -57,6 +57,7 @@ class Model(ModelBase):
return l3 return l3
def train_net(self): def train_net(self):
self.model._init_slots()
wide_input = self._dense_data_var[0] wide_input = self._dense_data_var[0]
deep_input = self._dense_data_var[1] deep_input = self._dense_data_var[1]
label = self._sparse_data_var[0] label = self._sparse_data_var[0]
...@@ -102,4 +103,5 @@ class Model(ModelBase): ...@@ -102,4 +103,5 @@ class Model(ModelBase):
return optimizer return optimizer
def infer_net(self, parameter_list): def infer_net(self, parameter_list):
self.model._init_slots()
self.deepfm_net() self.deepfm_net()
...@@ -145,6 +145,7 @@ class Model(ModelBase): ...@@ -145,6 +145,7 @@ class Model(ModelBase):
self.predict = fluid.layers.sigmoid(y_linear + y_cin + y_dnn) self.predict = fluid.layers.sigmoid(y_linear + y_cin + y_dnn)
def train_net(self): def train_net(self):
self.model._init_slots()
self.xdeepfm_net() self.xdeepfm_net()
cost = fluid.layers.log_loss(input=self.predict, label=fluid.layers.cast(self.label, "float32"), epsilon=0.0000001) cost = fluid.layers.log_loss(input=self.predict, label=fluid.layers.cast(self.label, "float32"), epsilon=0.0000001)
...@@ -166,4 +167,5 @@ class Model(ModelBase): ...@@ -166,4 +167,5 @@ class Model(ModelBase):
return optimizer return optimizer
def infer_net(self, parameter_list): def infer_net(self, parameter_list):
self.model._init_slots()
self.xdeepfm_net() self.xdeepfm_net()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册