提交 de7b6548 编写于 作者: F frankwhzhang

add logging for info

上级 b5e95a80
...@@ -17,12 +17,15 @@ from __future__ import print_function ...@@ -17,12 +17,15 @@ from __future__ import print_function
import os import os
import time import time
import numpy as np import numpy as np
from datetime import datetime import logging
import paddle.fluid as fluid import paddle.fluid as fluid
from paddlerec.core.utils import envs from paddlerec.core.utils import envs
from paddlerec.core.metric import Metric from paddlerec.core.metric import Metric
logging.basicConfig(
format='%(asctime)s - %(levelname)s: %(message)s', level=logging.INFO)
__all__ = [ __all__ = [
"RunnerBase", "SingleRunner", "PSRunner", "CollectiveRunner", "PslibRunner" "RunnerBase", "SingleRunner", "PSRunner", "CollectiveRunner", "PslibRunner"
] ]
...@@ -142,9 +145,9 @@ class RunnerBase(object): ...@@ -142,9 +145,9 @@ class RunnerBase(object):
metrics_format = [] metrics_format = []
if context["is_infer"]: if context["is_infer"]:
metrics_format.append("{{}}\t[Infer]\t{}: {{}}".format("batch")) metrics_format.append("\t[Infer]\t{}: {{}}".format("batch"))
else: else:
metrics_format.append("{{}}\t[Train]\t{}: {{}}".format("batch")) metrics_format.append("\t[Train]\t{}: {{}}".format("batch"))
metrics_format.append("{}: {{:.2f}}s".format("time_each_interval")) metrics_format.append("{}: {{:.2f}}s".format("time_each_interval"))
...@@ -170,10 +173,7 @@ class RunnerBase(object): ...@@ -170,10 +173,7 @@ class RunnerBase(object):
return_numpy=False) return_numpy=False)
if batch_id % fetch_period == 0 and batch_id != 0: if batch_id % fetch_period == 0 and batch_id != 0:
metrics = [ metrics = [batch_id]
datetime.now().strftime('%Y-%m-%d %H:%M:%S')
]
metrics.extend([batch_id])
end_time = time.time() end_time = time.time()
seconds = end_time - begin_time seconds = end_time - begin_time
metrics.extend([seconds]) metrics.extend([seconds])
...@@ -184,8 +184,7 @@ class RunnerBase(object): ...@@ -184,8 +184,7 @@ class RunnerBase(object):
for metrics_tensor in metrics_tensors for metrics_tensor in metrics_tensors
] ]
metrics.extend(metrics_rets) metrics.extend(metrics_rets)
logging.info(metrics_format.format(*metrics))
print(metrics_format.format(*metrics))
batch_id += 1 batch_id += 1
except fluid.core.EOFException: except fluid.core.EOFException:
reader.reset() reader.reset()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册