提交 40023f76 编写于 作者: W WenmuZhou

修复ips和batch_cost输出错误的bug

上级 0c287c41
...@@ -236,7 +236,6 @@ def train(config, ...@@ -236,7 +236,6 @@ def train(config,
train_batch_cost = 0.0 train_batch_cost = 0.0
train_reader_cost = 0.0 train_reader_cost = 0.0
batch_sum = 0 batch_sum = 0
batch_start = time.time()
# eval # eval
if global_step > start_eval_step and \ if global_step > start_eval_step and \
(global_step - start_eval_step) % eval_batch_step == 0 and dist.get_rank() == 0: (global_step - start_eval_step) % eval_batch_step == 0 and dist.get_rank() == 0:
...@@ -275,6 +274,7 @@ def train(config, ...@@ -275,6 +274,7 @@ def train(config,
best_model_dict[main_indicator], best_model_dict[main_indicator],
global_step) global_step)
global_step += 1 global_step += 1
batch_start = time.time()
if dist.get_rank() == 0: if dist.get_rank() == 0:
save_model( save_model(
model, model,
...@@ -334,17 +334,19 @@ def eval(model, valid_dataloader, post_process_class, eval_class): ...@@ -334,17 +334,19 @@ def eval(model, valid_dataloader, post_process_class, eval_class):
def save_inference_mode(model, config, logger): def save_inference_mode(model, config, logger):
model.eval() if dist.get_rank() == 0:
save_path = '{}/infer/{}'.format(config['Global']['save_model_dir'], model.eval()
config['Architecture']['model_type']) print('infer')
if config['Architecture']['model_type'] == 'rec': save_path = '{}/infer/{}'.format(config['Global']['save_model_dir'],
input_shape = [None, 3, 32, None] config['Architecture']['model_type'])
jit_model = paddle.jit.to_static( if config['Architecture']['model_type'] == 'rec':
model, input_spec=[paddle.static.InputSpec(input_shape)]) input_shape = [None, 3, 32, None]
paddle.jit.save(jit_model, save_path) jit_model = paddle.jit.to_static(
logger.info('inference model save to {}'.format(save_path)) model, input_spec=[paddle.static.InputSpec(input_shape)])
paddle.jit.save(jit_model, save_path)
model.train() logger.info('inference model save to {}'.format(save_path))
model.train()
def preprocess(): def preprocess():
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册