diff --git a/models/recall/fasttext/model.py b/models/recall/fasttext/model.py index 4a538f56dec514d8425a6a5a67214413d641e966..5b98dd7152c69652f1ff2acaa87ef77936017257 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 4c5abedacc736900368b4e91939b085df2d24945..fe32274c94accf46e154f0691e96edc7496a2dc3 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