提交 fb47984d 编写于 作者: M malin10

code style

上级 1aa218f3
...@@ -130,8 +130,8 @@ class Model(ModelBase): ...@@ -130,8 +130,8 @@ class Model(ModelBase):
loss = fluid.layers.log_loss(fluid.layers.sigmoid(logits), label) loss = fluid.layers.log_loss(fluid.layers.sigmoid(logits), label)
avg_cost = fluid.layers.reduce_sum(loss) 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", name="global_right_cnt",
persistable=True, persistable=True,
dtype='float32', dtype='float32',
...@@ -144,7 +144,7 @@ class Model(ModelBase): ...@@ -144,7 +144,7 @@ class Model(ModelBase):
shape=[1], shape=[1],
value=0) value=0)
global_right_cnt.stop_gradient = True global_right_cnt.stop_gradient = True
global_total_cnt.stop_gradient = True global_total_cnt.stop_gradient = True
self._cost = avg_cost self._cost = avg_cost
self._metrics["LOSS"] = avg_cost self._metrics["LOSS"] = avg_cost
...@@ -211,7 +211,7 @@ class Model(ModelBase): ...@@ -211,7 +211,7 @@ class Model(ModelBase):
tmp1 = fluid.layers.elementwise_add(right_cnt, global_right_cnt) tmp1 = fluid.layers.elementwise_add(right_cnt, global_right_cnt)
fluid.layers.assign(tmp1, global_right_cnt) fluid.layers.assign(tmp1, global_right_cnt)
tmp2 = fluid.layers.elementwise_add(total_cnt, global_total_cnt) tmp2 = fluid.layers.elementwise_add(total_cnt, global_total_cnt)
fluid.layers.assign(tmp2, global_total_cnt) fluid.layers.assign(tmp2, global_total_cnt)
......
...@@ -50,8 +50,8 @@ def parse_args(): ...@@ -50,8 +50,8 @@ def parse_args():
default='./word_ngrams', default='./word_ngrams',
help="The path of word_ngrams ") help="The path of word_ngrams ")
parser.add_argument( parser.add_argument(
'--ngrams_id_path', '--ngrams_id_path',
type=str, type=str,
default='./word_ngrams_id', default='./word_ngrams_id',
help="The path of word_ngrams_id ") help="The path of word_ngrams_id ")
parser.add_argument( parser.add_argument(
...@@ -157,8 +157,7 @@ def filter_corpus(args): ...@@ -157,8 +157,7 @@ def filter_corpus(args):
# write word2id file # write word2id file
print("write word2id file to : " + args.dict_path + "_word_to_id_") print("write word2id file to : " + args.dict_path + "_word_to_id_")
with io.open( with io.open(args.word_id_path, 'w+', encoding='utf-8') as fid:
args.word_id_path, 'w+', encoding='utf-8') as fid:
for k, v in word_to_id_.items(): for k, v in word_to_id_.items():
fid.write(k + " " + str(v) + '\n') fid.write(k + " " + str(v) + '\n')
# filter corpus and convert id # filter corpus and convert id
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册