From fb47984d69b230353229199f2cd3fd160d704b4c Mon Sep 17 00:00:00 2001 From: malin10 Date: Tue, 2 Jun 2020 11:32:17 +0800 Subject: [PATCH] code style --- models/recall/fasttext/model.py | 8 ++++---- models/recall/fasttext/preprocess.py | 7 +++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/models/recall/fasttext/model.py b/models/recall/fasttext/model.py index 4a538f56..5b98dd71 100755 --- a/models/recall/fasttext/model.py +++ b/models/recall/fasttext/model.py @@ -130,8 +130,8 @@ class Model(ModelBase): loss = fluid.layers.log_loss(fluid.layers.sigmoid(logits), label) avg_cost = fluid.layers.reduce_sum(loss) - - global_right_cnt = fluid.layers.create_global_var( + + global_right_cnt = fluid.layers.create_global_var( name="global_right_cnt", persistable=True, dtype='float32', @@ -144,7 +144,7 @@ class Model(ModelBase): shape=[1], value=0) global_right_cnt.stop_gradient = True - global_total_cnt.stop_gradient = True + global_total_cnt.stop_gradient = True self._cost = avg_cost self._metrics["LOSS"] = avg_cost @@ -211,7 +211,7 @@ class Model(ModelBase): tmp1 = fluid.layers.elementwise_add(right_cnt, global_right_cnt) fluid.layers.assign(tmp1, global_right_cnt) - + tmp2 = fluid.layers.elementwise_add(total_cnt, global_total_cnt) fluid.layers.assign(tmp2, global_total_cnt) diff --git a/models/recall/fasttext/preprocess.py b/models/recall/fasttext/preprocess.py index 4c5abeda..fe32274c 100755 --- a/models/recall/fasttext/preprocess.py +++ b/models/recall/fasttext/preprocess.py @@ -50,8 +50,8 @@ def parse_args(): default='./word_ngrams', help="The path of word_ngrams ") parser.add_argument( - '--ngrams_id_path', - type=str, + '--ngrams_id_path', + type=str, default='./word_ngrams_id', help="The path of word_ngrams_id ") parser.add_argument( @@ -157,8 +157,7 @@ def filter_corpus(args): # write word2id file print("write word2id file to : " + args.dict_path + "_word_to_id_") - with io.open( - args.word_id_path, 'w+', encoding='utf-8') as fid: + with io.open(args.word_id_path, 'w+', encoding='utf-8') as fid: for k, v in word_to_id_.items(): fid.write(k + " " + str(v) + '\n') # filter corpus and convert id -- GitLab