未验证 提交 747f947e 编写于 作者: J Jiabin Yang 提交者: GitHub

Merge pull request #1674 from JiabinYang/fix_train_without_third_party_vocab

fix fix_train_without_third_party_vocab
...@@ -70,8 +70,8 @@ class Word2VecReader(object): ...@@ -70,8 +70,8 @@ class Word2VecReader(object):
self.word_frequencys = [ self.word_frequencys = [
float(count) / word_all_count for count in word_counts float(count) / word_all_count for count in word_counts
] ]
print("dict_size = " + str( print("dict_size = " + str(self.dict_size) + " word_all_count = " + str(
self.dict_size)) + " word_all_count = " + str(word_all_count) word_all_count))
with io.open(dict_path + "_ptable", 'r', encoding='utf-8') as f2: with io.open(dict_path + "_ptable", 'r', encoding='utf-8') as f2:
for line in f2: for line in f2:
......
...@@ -203,7 +203,7 @@ def train_loop(args, train_program, reader, py_reader, loss, trainer_id): ...@@ -203,7 +203,7 @@ def train_loop(args, train_program, reader, py_reader, loss, trainer_id):
time.sleep(10) time.sleep(10)
epoch_start = time.time() epoch_start = time.time()
batch_id = 0 batch_id = 0
start = time.clock() start = time.time()
try: try:
while True: while True:
...@@ -218,8 +218,8 @@ def train_loop(args, train_program, reader, py_reader, loss, trainer_id): ...@@ -218,8 +218,8 @@ def train_loop(args, train_program, reader, py_reader, loss, trainer_id):
loss_val.mean(), py_reader.queue.size())) loss_val.mean(), py_reader.queue.size()))
if args.with_speed: if args.with_speed:
if batch_id % 1000 == 0 and batch_id != 0: if batch_id % 1000 == 0 and batch_id != 0:
elapsed = (time.clock() - start) elapsed = (time.time() - start)
start = time.clock() start = time.time()
samples = 1001 * args.batch_size * int( samples = 1001 * args.batch_size * int(
os.getenv("CPU_NUM")) os.getenv("CPU_NUM"))
logger.info("Time used: {}, Samples/Sec: {}".format( logger.info("Time used: {}, Samples/Sec: {}".format(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册