Add a high-level API with traning and inference into Paddle. (#24293)
* Merge hapi into Paddle
Hapi is a high level API for training and inference.
The main modules include Model, Loss, Metrics, Dataset.
Also includes common modules and models in NLP and computer vision, such as BERT, ResNet.
These modules are developed by:
0YuanZhang0, guoshengCS heavengate, LielinJiang, qingqing01, xyzhou-puck huangjun12, wangxiao1021, zhangyang.
2020-05-11 05:14:13 -05:00
|
|
|
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
|
|
|
|
|
#
|
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
|
#
|
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
#
|
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
|
# limitations under the License.
|
|
|
|
|
|
|
|
|
|
import os
|
2022-12-01 09:59:11 +08:00
|
|
|
import struct
|
Add a high-level API with traning and inference into Paddle. (#24293)
* Merge hapi into Paddle
Hapi is a high level API for training and inference.
The main modules include Model, Loss, Metrics, Dataset.
Also includes common modules and models in NLP and computer vision, such as BERT, ResNet.
These modules are developed by:
0YuanZhang0, guoshengCS heavengate, LielinJiang, qingqing01, xyzhou-puck huangjun12, wangxiao1021, zhangyang.
2020-05-11 05:14:13 -05:00
|
|
|
import sys
|
|
|
|
|
import time
|
2022-12-01 09:59:11 +08:00
|
|
|
|
Add a high-level API with traning and inference into Paddle. (#24293)
* Merge hapi into Paddle
Hapi is a high level API for training and inference.
The main modules include Model, Loss, Metrics, Dataset.
Also includes common modules and models in NLP and computer vision, such as BERT, ResNet.
These modules are developed by:
0YuanZhang0, guoshengCS heavengate, LielinJiang, qingqing01, xyzhou-puck huangjun12, wangxiao1021, zhangyang.
2020-05-11 05:14:13 -05:00
|
|
|
import numpy as np
|
|
|
|
|
|
2021-04-29 08:38:52 +08:00
|
|
|
__all__ = []
|
Add a high-level API with traning and inference into Paddle. (#24293)
* Merge hapi into Paddle
Hapi is a high level API for training and inference.
The main modules include Model, Loss, Metrics, Dataset.
Also includes common modules and models in NLP and computer vision, such as BERT, ResNet.
These modules are developed by:
0YuanZhang0, guoshengCS heavengate, LielinJiang, qingqing01, xyzhou-puck huangjun12, wangxiao1021, zhangyang.
2020-05-11 05:14:13 -05:00
|
|
|
|
|
|
|
|
|
2022-11-08 11:29:41 +08:00
|
|
|
class ProgressBar:
|
2022-10-23 20:01:27 +08:00
|
|
|
"""progress bar"""
|
|
|
|
|
|
|
|
|
|
def __init__(
|
|
|
|
|
self,
|
|
|
|
|
num=None,
|
|
|
|
|
width=30,
|
|
|
|
|
verbose=1,
|
|
|
|
|
start=True,
|
|
|
|
|
file=sys.stdout,
|
|
|
|
|
name='step',
|
|
|
|
|
):
|
Add a high-level API with traning and inference into Paddle. (#24293)
* Merge hapi into Paddle
Hapi is a high level API for training and inference.
The main modules include Model, Loss, Metrics, Dataset.
Also includes common modules and models in NLP and computer vision, such as BERT, ResNet.
These modules are developed by:
0YuanZhang0, guoshengCS heavengate, LielinJiang, qingqing01, xyzhou-puck huangjun12, wangxiao1021, zhangyang.
2020-05-11 05:14:13 -05:00
|
|
|
self._num = num
|
|
|
|
|
if isinstance(num, int) and num <= 0:
|
|
|
|
|
raise TypeError('num should be None or integer (> 0)')
|
|
|
|
|
max_width = self._get_max_width()
|
2024-08-10 03:40:52 +08:00
|
|
|
self._width = min(width, max_width)
|
Add a high-level API with traning and inference into Paddle. (#24293)
* Merge hapi into Paddle
Hapi is a high level API for training and inference.
The main modules include Model, Loss, Metrics, Dataset.
Also includes common modules and models in NLP and computer vision, such as BERT, ResNet.
These modules are developed by:
0YuanZhang0, guoshengCS heavengate, LielinJiang, qingqing01, xyzhou-puck huangjun12, wangxiao1021, zhangyang.
2020-05-11 05:14:13 -05:00
|
|
|
self._total_width = 0
|
|
|
|
|
self._verbose = verbose
|
|
|
|
|
self.file = file
|
|
|
|
|
self._values = {}
|
|
|
|
|
self._values_order = []
|
|
|
|
|
if start:
|
|
|
|
|
self._start = time.time()
|
|
|
|
|
self._last_update = 0
|
2021-06-03 16:44:44 +08:00
|
|
|
self.name = name
|
Add a high-level API with traning and inference into Paddle. (#24293)
* Merge hapi into Paddle
Hapi is a high level API for training and inference.
The main modules include Model, Loss, Metrics, Dataset.
Also includes common modules and models in NLP and computer vision, such as BERT, ResNet.
These modules are developed by:
0YuanZhang0, guoshengCS heavengate, LielinJiang, qingqing01, xyzhou-puck huangjun12, wangxiao1021, zhangyang.
2020-05-11 05:14:13 -05:00
|
|
|
|
2022-10-23 20:01:27 +08:00
|
|
|
self._dynamic_display = (
|
|
|
|
|
(hasattr(self.file, 'isatty') and self.file.isatty())
|
|
|
|
|
or 'ipykernel' in sys.modules
|
|
|
|
|
or 'posix' in sys.modules
|
|
|
|
|
or 'PYCHARM_HOSTED' in os.environ
|
|
|
|
|
)
|
Add a high-level API with traning and inference into Paddle. (#24293)
* Merge hapi into Paddle
Hapi is a high level API for training and inference.
The main modules include Model, Loss, Metrics, Dataset.
Also includes common modules and models in NLP and computer vision, such as BERT, ResNet.
These modules are developed by:
0YuanZhang0, guoshengCS heavengate, LielinJiang, qingqing01, xyzhou-puck huangjun12, wangxiao1021, zhangyang.
2020-05-11 05:14:13 -05:00
|
|
|
|
|
|
|
|
def _get_max_width(self):
|
2022-11-29 10:16:50 +08:00
|
|
|
from shutil import get_terminal_size
|
Add a high-level API with traning and inference into Paddle. (#24293)
* Merge hapi into Paddle
Hapi is a high level API for training and inference.
The main modules include Model, Loss, Metrics, Dataset.
Also includes common modules and models in NLP and computer vision, such as BERT, ResNet.
These modules are developed by:
0YuanZhang0, guoshengCS heavengate, LielinJiang, qingqing01, xyzhou-puck huangjun12, wangxiao1021, zhangyang.
2020-05-11 05:14:13 -05:00
|
|
|
|
|
|
|
|
terminal_width, _ = get_terminal_size()
|
2020-08-31 12:39:43 +08:00
|
|
|
terminal_width = terminal_width if terminal_width > 0 else 80
|
Add a high-level API with traning and inference into Paddle. (#24293)
* Merge hapi into Paddle
Hapi is a high level API for training and inference.
The main modules include Model, Loss, Metrics, Dataset.
Also includes common modules and models in NLP and computer vision, such as BERT, ResNet.
These modules are developed by:
0YuanZhang0, guoshengCS heavengate, LielinJiang, qingqing01, xyzhou-puck huangjun12, wangxiao1021, zhangyang.
2020-05-11 05:14:13 -05:00
|
|
|
max_width = min(int(terminal_width * 0.6), terminal_width - 50)
|
|
|
|
|
return max_width
|
|
|
|
|
|
|
|
|
|
def start(self):
|
|
|
|
|
self.file.flush()
|
|
|
|
|
self._start = time.time()
|
|
|
|
|
|
2021-06-03 16:44:44 +08:00
|
|
|
def update(self, current_num, values={}):
|
Add a high-level API with traning and inference into Paddle. (#24293)
* Merge hapi into Paddle
Hapi is a high level API for training and inference.
The main modules include Model, Loss, Metrics, Dataset.
Also includes common modules and models in NLP and computer vision, such as BERT, ResNet.
These modules are developed by:
0YuanZhang0, guoshengCS heavengate, LielinJiang, qingqing01, xyzhou-puck huangjun12, wangxiao1021, zhangyang.
2020-05-11 05:14:13 -05:00
|
|
|
now = time.time()
|
|
|
|
|
|
2022-02-21 08:35:49 +01:00
|
|
|
def convert_uint16_to_float(in_list):
|
|
|
|
|
in_list = np.asarray(in_list)
|
|
|
|
|
out = np.vectorize(
|
|
|
|
|
lambda x: struct.unpack('<f', struct.pack('<I', x << 16))[0],
|
2022-10-23 20:01:27 +08:00
|
|
|
otypes=[np.float32],
|
|
|
|
|
)(in_list.flat)
|
2022-02-21 08:35:49 +01:00
|
|
|
return np.reshape(out, in_list.shape)
|
|
|
|
|
|
|
|
|
|
for i, (k, val) in enumerate(values):
|
|
|
|
|
if k == "loss":
|
2023-04-24 20:25:29 +08:00
|
|
|
if isinstance(val, list):
|
|
|
|
|
scalar_val = val[0]
|
|
|
|
|
else:
|
|
|
|
|
scalar_val = val
|
|
|
|
|
if isinstance(scalar_val, np.uint16):
|
2022-02-21 08:35:49 +01:00
|
|
|
values[i] = ("loss", list(convert_uint16_to_float(val)))
|
|
|
|
|
|
Add a high-level API with traning and inference into Paddle. (#24293)
* Merge hapi into Paddle
Hapi is a high level API for training and inference.
The main modules include Model, Loss, Metrics, Dataset.
Also includes common modules and models in NLP and computer vision, such as BERT, ResNet.
These modules are developed by:
0YuanZhang0, guoshengCS heavengate, LielinJiang, qingqing01, xyzhou-puck huangjun12, wangxiao1021, zhangyang.
2020-05-11 05:14:13 -05:00
|
|
|
if current_num:
|
|
|
|
|
time_per_unit = (now - self._start) / current_num
|
|
|
|
|
else:
|
|
|
|
|
time_per_unit = 0
|
|
|
|
|
|
|
|
|
|
if time_per_unit >= 1 or time_per_unit == 0:
|
2023-03-31 10:11:56 +08:00
|
|
|
fps = f' - {time_per_unit:.0f}s/{self.name}'
|
Add a high-level API with traning and inference into Paddle. (#24293)
* Merge hapi into Paddle
Hapi is a high level API for training and inference.
The main modules include Model, Loss, Metrics, Dataset.
Also includes common modules and models in NLP and computer vision, such as BERT, ResNet.
These modules are developed by:
0YuanZhang0, guoshengCS heavengate, LielinJiang, qingqing01, xyzhou-puck huangjun12, wangxiao1021, zhangyang.
2020-05-11 05:14:13 -05:00
|
|
|
elif time_per_unit >= 1e-3:
|
2023-09-22 10:14:38 +08:00
|
|
|
fps = f' - {time_per_unit * 1e3:.0f}ms/{self.name}'
|
Add a high-level API with traning and inference into Paddle. (#24293)
* Merge hapi into Paddle
Hapi is a high level API for training and inference.
The main modules include Model, Loss, Metrics, Dataset.
Also includes common modules and models in NLP and computer vision, such as BERT, ResNet.
These modules are developed by:
0YuanZhang0, guoshengCS heavengate, LielinJiang, qingqing01, xyzhou-puck huangjun12, wangxiao1021, zhangyang.
2020-05-11 05:14:13 -05:00
|
|
|
else:
|
2023-09-22 10:14:38 +08:00
|
|
|
fps = f' - {time_per_unit * 1e6:.0f}us/{self.name}'
|
Add a high-level API with traning and inference into Paddle. (#24293)
* Merge hapi into Paddle
Hapi is a high level API for training and inference.
The main modules include Model, Loss, Metrics, Dataset.
Also includes common modules and models in NLP and computer vision, such as BERT, ResNet.
These modules are developed by:
0YuanZhang0, guoshengCS heavengate, LielinJiang, qingqing01, xyzhou-puck huangjun12, wangxiao1021, zhangyang.
2020-05-11 05:14:13 -05:00
|
|
|
|
|
|
|
|
info = ''
|
|
|
|
|
if self._verbose == 1:
|
|
|
|
|
prev_total_width = self._total_width
|
|
|
|
|
|
|
|
|
|
if self._dynamic_display:
|
|
|
|
|
sys.stdout.write('\b' * prev_total_width)
|
|
|
|
|
sys.stdout.write('\r')
|
|
|
|
|
else:
|
|
|
|
|
sys.stdout.write('\n')
|
|
|
|
|
|
|
|
|
|
if self._num is not None:
|
|
|
|
|
numdigits = int(np.log10(self._num)) + 1
|
|
|
|
|
|
2022-10-23 20:01:27 +08:00
|
|
|
bar_chars = (self.name + ' %' + str(numdigits) + 'd/%d [') % (
|
|
|
|
|
current_num,
|
|
|
|
|
self._num,
|
|
|
|
|
)
|
Add a high-level API with traning and inference into Paddle. (#24293)
* Merge hapi into Paddle
Hapi is a high level API for training and inference.
The main modules include Model, Loss, Metrics, Dataset.
Also includes common modules and models in NLP and computer vision, such as BERT, ResNet.
These modules are developed by:
0YuanZhang0, guoshengCS heavengate, LielinJiang, qingqing01, xyzhou-puck huangjun12, wangxiao1021, zhangyang.
2020-05-11 05:14:13 -05:00
|
|
|
prog = float(current_num) / self._num
|
|
|
|
|
prog_width = int(self._width * prog)
|
|
|
|
|
|
|
|
|
|
if prog_width > 0:
|
2022-10-23 20:01:27 +08:00
|
|
|
bar_chars += '=' * (prog_width - 1)
|
Add a high-level API with traning and inference into Paddle. (#24293)
* Merge hapi into Paddle
Hapi is a high level API for training and inference.
The main modules include Model, Loss, Metrics, Dataset.
Also includes common modules and models in NLP and computer vision, such as BERT, ResNet.
These modules are developed by:
0YuanZhang0, guoshengCS heavengate, LielinJiang, qingqing01, xyzhou-puck huangjun12, wangxiao1021, zhangyang.
2020-05-11 05:14:13 -05:00
|
|
|
if current_num < self._num:
|
|
|
|
|
bar_chars += '>'
|
|
|
|
|
else:
|
|
|
|
|
bar_chars += '='
|
2022-10-23 20:01:27 +08:00
|
|
|
bar_chars += '.' * (self._width - prog_width)
|
Add a high-level API with traning and inference into Paddle. (#24293)
* Merge hapi into Paddle
Hapi is a high level API for training and inference.
The main modules include Model, Loss, Metrics, Dataset.
Also includes common modules and models in NLP and computer vision, such as BERT, ResNet.
These modules are developed by:
0YuanZhang0, guoshengCS heavengate, LielinJiang, qingqing01, xyzhou-puck huangjun12, wangxiao1021, zhangyang.
2020-05-11 05:14:13 -05:00
|
|
|
bar_chars += ']'
|
|
|
|
|
else:
|
2024-12-08 11:45:43 +08:00
|
|
|
bar_chars = f'{self.name} {current_num:3}'
|
Add a high-level API with traning and inference into Paddle. (#24293)
* Merge hapi into Paddle
Hapi is a high level API for training and inference.
The main modules include Model, Loss, Metrics, Dataset.
Also includes common modules and models in NLP and computer vision, such as BERT, ResNet.
These modules are developed by:
0YuanZhang0, guoshengCS heavengate, LielinJiang, qingqing01, xyzhou-puck huangjun12, wangxiao1021, zhangyang.
2020-05-11 05:14:13 -05:00
|
|
|
|
|
|
|
|
self._total_width = len(bar_chars)
|
|
|
|
|
sys.stdout.write(bar_chars)
|
|
|
|
|
|
|
|
|
|
for k, val in values:
|
2024-06-30 15:16:14 +08:00
|
|
|
info += f' - {k}:'
|
Add a high-level API with traning and inference into Paddle. (#24293)
* Merge hapi into Paddle
Hapi is a high level API for training and inference.
The main modules include Model, Loss, Metrics, Dataset.
Also includes common modules and models in NLP and computer vision, such as BERT, ResNet.
These modules are developed by:
0YuanZhang0, guoshengCS heavengate, LielinJiang, qingqing01, xyzhou-puck huangjun12, wangxiao1021, zhangyang.
2020-05-11 05:14:13 -05:00
|
|
|
val = val if isinstance(val, list) else [val]
|
|
|
|
|
for i, v in enumerate(val):
|
|
|
|
|
if isinstance(v, (float, np.float32, np.float64)):
|
|
|
|
|
if abs(v) > 1e-3:
|
2024-06-30 15:16:14 +08:00
|
|
|
info += f' {v:.4f}'
|
Add a high-level API with traning and inference into Paddle. (#24293)
* Merge hapi into Paddle
Hapi is a high level API for training and inference.
The main modules include Model, Loss, Metrics, Dataset.
Also includes common modules and models in NLP and computer vision, such as BERT, ResNet.
These modules are developed by:
0YuanZhang0, guoshengCS heavengate, LielinJiang, qingqing01, xyzhou-puck huangjun12, wangxiao1021, zhangyang.
2020-05-11 05:14:13 -05:00
|
|
|
else:
|
2024-06-30 15:16:14 +08:00
|
|
|
info += f' {v:.4e}'
|
Add a high-level API with traning and inference into Paddle. (#24293)
* Merge hapi into Paddle
Hapi is a high level API for training and inference.
The main modules include Model, Loss, Metrics, Dataset.
Also includes common modules and models in NLP and computer vision, such as BERT, ResNet.
These modules are developed by:
0YuanZhang0, guoshengCS heavengate, LielinJiang, qingqing01, xyzhou-puck huangjun12, wangxiao1021, zhangyang.
2020-05-11 05:14:13 -05:00
|
|
|
else:
|
2024-06-30 15:16:14 +08:00
|
|
|
info += f' {v}'
|
Add a high-level API with traning and inference into Paddle. (#24293)
* Merge hapi into Paddle
Hapi is a high level API for training and inference.
The main modules include Model, Loss, Metrics, Dataset.
Also includes common modules and models in NLP and computer vision, such as BERT, ResNet.
These modules are developed by:
0YuanZhang0, guoshengCS heavengate, LielinJiang, qingqing01, xyzhou-puck huangjun12, wangxiao1021, zhangyang.
2020-05-11 05:14:13 -05:00
|
|
|
|
|
|
|
|
if self._num is not None and current_num < self._num:
|
2025-10-13 11:59:34 +08:00
|
|
|
eta = int(time_per_unit * (self._num - current_num))
|
Add a high-level API with traning and inference into Paddle. (#24293)
* Merge hapi into Paddle
Hapi is a high level API for training and inference.
The main modules include Model, Loss, Metrics, Dataset.
Also includes common modules and models in NLP and computer vision, such as BERT, ResNet.
These modules are developed by:
0YuanZhang0, guoshengCS heavengate, LielinJiang, qingqing01, xyzhou-puck huangjun12, wangxiao1021, zhangyang.
2020-05-11 05:14:13 -05:00
|
|
|
if eta > 3600:
|
2024-12-08 11:45:43 +08:00
|
|
|
eta_format = (
|
|
|
|
|
f'{eta // 3600}:{(eta % 3600) // 60:02}:{eta % 60:02}'
|
2022-10-23 20:01:27 +08:00
|
|
|
)
|
Add a high-level API with traning and inference into Paddle. (#24293)
* Merge hapi into Paddle
Hapi is a high level API for training and inference.
The main modules include Model, Loss, Metrics, Dataset.
Also includes common modules and models in NLP and computer vision, such as BERT, ResNet.
These modules are developed by:
0YuanZhang0, guoshengCS heavengate, LielinJiang, qingqing01, xyzhou-puck huangjun12, wangxiao1021, zhangyang.
2020-05-11 05:14:13 -05:00
|
|
|
elif eta > 60:
|
2024-12-08 11:45:43 +08:00
|
|
|
eta_format = f'{eta // 60}:{eta % 60:02}'
|
Add a high-level API with traning and inference into Paddle. (#24293)
* Merge hapi into Paddle
Hapi is a high level API for training and inference.
The main modules include Model, Loss, Metrics, Dataset.
Also includes common modules and models in NLP and computer vision, such as BERT, ResNet.
These modules are developed by:
0YuanZhang0, guoshengCS heavengate, LielinJiang, qingqing01, xyzhou-puck huangjun12, wangxiao1021, zhangyang.
2020-05-11 05:14:13 -05:00
|
|
|
else:
|
2024-12-08 11:45:43 +08:00
|
|
|
eta_format = f'{eta}s'
|
Add a high-level API with traning and inference into Paddle. (#24293)
* Merge hapi into Paddle
Hapi is a high level API for training and inference.
The main modules include Model, Loss, Metrics, Dataset.
Also includes common modules and models in NLP and computer vision, such as BERT, ResNet.
These modules are developed by:
0YuanZhang0, guoshengCS heavengate, LielinJiang, qingqing01, xyzhou-puck huangjun12, wangxiao1021, zhangyang.
2020-05-11 05:14:13 -05:00
|
|
|
|
2024-06-30 15:16:14 +08:00
|
|
|
info += f' - ETA: {eta_format}'
|
Add a high-level API with traning and inference into Paddle. (#24293)
* Merge hapi into Paddle
Hapi is a high level API for training and inference.
The main modules include Model, Loss, Metrics, Dataset.
Also includes common modules and models in NLP and computer vision, such as BERT, ResNet.
These modules are developed by:
0YuanZhang0, guoshengCS heavengate, LielinJiang, qingqing01, xyzhou-puck huangjun12, wangxiao1021, zhangyang.
2020-05-11 05:14:13 -05:00
|
|
|
|
|
|
|
|
info += fps
|
|
|
|
|
self._total_width += len(info)
|
|
|
|
|
if prev_total_width > self._total_width:
|
2022-10-23 20:01:27 +08:00
|
|
|
info += ' ' * (prev_total_width - self._total_width)
|
Add a high-level API with traning and inference into Paddle. (#24293)
* Merge hapi into Paddle
Hapi is a high level API for training and inference.
The main modules include Model, Loss, Metrics, Dataset.
Also includes common modules and models in NLP and computer vision, such as BERT, ResNet.
These modules are developed by:
0YuanZhang0, guoshengCS heavengate, LielinJiang, qingqing01, xyzhou-puck huangjun12, wangxiao1021, zhangyang.
2020-05-11 05:14:13 -05:00
|
|
|
|
|
|
|
|
# newline for another epoch
|
|
|
|
|
if self._num is not None and current_num >= self._num:
|
|
|
|
|
info += '\n'
|
|
|
|
|
if self._num is None:
|
|
|
|
|
info += '\n'
|
|
|
|
|
|
|
|
|
|
sys.stdout.write(info)
|
|
|
|
|
sys.stdout.flush()
|
|
|
|
|
self._last_update = now
|
2020-11-27 16:20:39 +08:00
|
|
|
elif self._verbose == 2 or self._verbose == 3:
|
Add a high-level API with traning and inference into Paddle. (#24293)
* Merge hapi into Paddle
Hapi is a high level API for training and inference.
The main modules include Model, Loss, Metrics, Dataset.
Also includes common modules and models in NLP and computer vision, such as BERT, ResNet.
These modules are developed by:
0YuanZhang0, guoshengCS heavengate, LielinJiang, qingqing01, xyzhou-puck huangjun12, wangxiao1021, zhangyang.
2020-05-11 05:14:13 -05:00
|
|
|
if self._num:
|
|
|
|
|
numdigits = int(np.log10(self._num)) + 1
|
2022-10-23 20:01:27 +08:00
|
|
|
count = (self.name + ' %' + str(numdigits) + 'd/%d') % (
|
|
|
|
|
current_num,
|
|
|
|
|
self._num,
|
|
|
|
|
)
|
Add a high-level API with traning and inference into Paddle. (#24293)
* Merge hapi into Paddle
Hapi is a high level API for training and inference.
The main modules include Model, Loss, Metrics, Dataset.
Also includes common modules and models in NLP and computer vision, such as BERT, ResNet.
These modules are developed by:
0YuanZhang0, guoshengCS heavengate, LielinJiang, qingqing01, xyzhou-puck huangjun12, wangxiao1021, zhangyang.
2020-05-11 05:14:13 -05:00
|
|
|
else:
|
2024-12-08 11:45:43 +08:00
|
|
|
count = f'{self.name} {current_num:3}'
|
Add a high-level API with traning and inference into Paddle. (#24293)
* Merge hapi into Paddle
Hapi is a high level API for training and inference.
The main modules include Model, Loss, Metrics, Dataset.
Also includes common modules and models in NLP and computer vision, such as BERT, ResNet.
These modules are developed by:
0YuanZhang0, guoshengCS heavengate, LielinJiang, qingqing01, xyzhou-puck huangjun12, wangxiao1021, zhangyang.
2020-05-11 05:14:13 -05:00
|
|
|
info = count + info
|
|
|
|
|
|
|
|
|
|
for k, val in values:
|
2024-06-30 15:16:14 +08:00
|
|
|
info += f' - {k}:'
|
Add a high-level API with traning and inference into Paddle. (#24293)
* Merge hapi into Paddle
Hapi is a high level API for training and inference.
The main modules include Model, Loss, Metrics, Dataset.
Also includes common modules and models in NLP and computer vision, such as BERT, ResNet.
These modules are developed by:
0YuanZhang0, guoshengCS heavengate, LielinJiang, qingqing01, xyzhou-puck huangjun12, wangxiao1021, zhangyang.
2020-05-11 05:14:13 -05:00
|
|
|
val = val if isinstance(val, list) else [val]
|
|
|
|
|
for v in val:
|
|
|
|
|
if isinstance(v, (float, np.float32, np.float64)):
|
|
|
|
|
if abs(v) > 1e-3:
|
2024-06-30 15:16:14 +08:00
|
|
|
info += f' {v:.4f}'
|
Add a high-level API with traning and inference into Paddle. (#24293)
* Merge hapi into Paddle
Hapi is a high level API for training and inference.
The main modules include Model, Loss, Metrics, Dataset.
Also includes common modules and models in NLP and computer vision, such as BERT, ResNet.
These modules are developed by:
0YuanZhang0, guoshengCS heavengate, LielinJiang, qingqing01, xyzhou-puck huangjun12, wangxiao1021, zhangyang.
2020-05-11 05:14:13 -05:00
|
|
|
else:
|
2024-06-30 15:16:14 +08:00
|
|
|
info += f' {v:.4e}'
|
2022-10-23 20:01:27 +08:00
|
|
|
elif (
|
|
|
|
|
isinstance(v, np.ndarray)
|
|
|
|
|
and v.size == 1
|
|
|
|
|
and v.dtype in [np.float32, np.float64]
|
|
|
|
|
):
|
2023-03-21 10:48:51 +08:00
|
|
|
if abs(v.item()) > 1e-3:
|
2024-06-30 15:16:14 +08:00
|
|
|
info += f' {v.item():.4f}'
|
Add a high-level API with traning and inference into Paddle. (#24293)
* Merge hapi into Paddle
Hapi is a high level API for training and inference.
The main modules include Model, Loss, Metrics, Dataset.
Also includes common modules and models in NLP and computer vision, such as BERT, ResNet.
These modules are developed by:
0YuanZhang0, guoshengCS heavengate, LielinJiang, qingqing01, xyzhou-puck huangjun12, wangxiao1021, zhangyang.
2020-05-11 05:14:13 -05:00
|
|
|
else:
|
2024-06-30 15:16:14 +08:00
|
|
|
info += f' {v.item():.4e}'
|
Add a high-level API with traning and inference into Paddle. (#24293)
* Merge hapi into Paddle
Hapi is a high level API for training and inference.
The main modules include Model, Loss, Metrics, Dataset.
Also includes common modules and models in NLP and computer vision, such as BERT, ResNet.
These modules are developed by:
0YuanZhang0, guoshengCS heavengate, LielinJiang, qingqing01, xyzhou-puck huangjun12, wangxiao1021, zhangyang.
2020-05-11 05:14:13 -05:00
|
|
|
else:
|
2024-06-30 15:16:14 +08:00
|
|
|
info += f' {v}'
|
Add a high-level API with traning and inference into Paddle. (#24293)
* Merge hapi into Paddle
Hapi is a high level API for training and inference.
The main modules include Model, Loss, Metrics, Dataset.
Also includes common modules and models in NLP and computer vision, such as BERT, ResNet.
These modules are developed by:
0YuanZhang0, guoshengCS heavengate, LielinJiang, qingqing01, xyzhou-puck huangjun12, wangxiao1021, zhangyang.
2020-05-11 05:14:13 -05:00
|
|
|
|
|
|
|
|
info += fps
|
|
|
|
|
info += '\n'
|
|
|
|
|
sys.stdout.write(info)
|
|
|
|
|
sys.stdout.flush()
|