From 189f986f072af798c14da7342bab4c4260cb6e69 Mon Sep 17 00:00:00 2001 From: yaoxuefeng Date: Tue, 2 Jun 2020 12:16:17 +0800 Subject: [PATCH] add lr fix codes --- models/rank/deepfm/data/get_slot_data.py | 6 ++++-- models/rank/logistic_regression/data/get_slot_data.py | 9 +++++++-- models/rank/logistic_regression/data/preprocess.py | 1 - 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/models/rank/deepfm/data/get_slot_data.py b/models/rank/deepfm/data/get_slot_data.py index 6177c990..c03b2924 100755 --- a/models/rank/deepfm/data/get_slot_data.py +++ b/models/rank/deepfm/data/get_slot_data.py @@ -12,9 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -import yaml +import yaml, os + from paddlerec.core.reader import Reader from paddlerec.core.utils import envs +import paddle.fluid.incubate.data_generator as dg try: import cPickle as pickle except ImportError: @@ -44,7 +46,7 @@ class TrainReader(dg.MultiSlotDataGenerator): self.continuous_range_ = range(1, 14) self.categorical_range_ = range(14, 40) # load preprocessed feature dict - self.feat_dict_name = "aid_data/feat_dict_10.pkl2" + self.feat_dict_name = "sample_data/feat_dict_10.pkl2" self.feat_dict_ = pickle.load(open(self.feat_dict_name, 'rb')) def _process_line(self, line): diff --git a/models/rank/logistic_regression/data/get_slot_data.py b/models/rank/logistic_regression/data/get_slot_data.py index 6177c990..799762ce 100755 --- a/models/rank/logistic_regression/data/get_slot_data.py +++ b/models/rank/logistic_regression/data/get_slot_data.py @@ -13,8 +13,12 @@ # limitations under the License. import yaml +import os + from paddlerec.core.reader import Reader from paddlerec.core.utils import envs +import paddle.fluid.incubate.data_generator as dg + try: import cPickle as pickle except ImportError: @@ -44,7 +48,7 @@ class TrainReader(dg.MultiSlotDataGenerator): self.continuous_range_ = range(1, 14) self.categorical_range_ = range(14, 40) # load preprocessed feature dict - self.feat_dict_name = "aid_data/feat_dict_10.pkl2" + self.feat_dict_name = "sample_data/feat_dict_10.pkl2" self.feat_dict_ = pickle.load(open(self.feat_dict_name, 'rb')) def _process_line(self, line): @@ -90,6 +94,7 @@ class TrainReader(dg.MultiSlotDataGenerator): return data_iter -reader = TrainReader("../config.yaml") +reader = TrainReader( + "../config.yaml") # run this file in original folder to find config.yaml reader.init() reader.run_from_stdin() diff --git a/models/rank/logistic_regression/data/preprocess.py b/models/rank/logistic_regression/data/preprocess.py index 9da3bdc3..0eaed5eb 100755 --- a/models/rank/logistic_regression/data/preprocess.py +++ b/models/rank/logistic_regression/data/preprocess.py @@ -66,7 +66,6 @@ def get_feat_dict(): categorical_range_ = range(14, 40) if not os.path.exists(dir_feat_dict_): - # print('generate a feature dict') # Count the number of occurrences of discrete features feat_cnt = Counter() with open('train.txt', 'r') as fin: -- GitLab