From 740cfa94078ca667142c3601b6d4434b2c9b9ddf Mon Sep 17 00:00:00 2001 From: piotrekobiIntel Date: Mon, 21 Feb 2022 08:35:49 +0100 Subject: [PATCH] Add loss conversion from uint16 to float in ProgressBar class (#39231) * Add loss conversion from uint16 to float in progressbar class * Fix test coverage * Actually fix coverage * Fix format error --- python/paddle/hapi/progressbar.py | 15 +++++++++++++++ python/paddle/tests/test_progressbar.py | 1 + 2 files changed, 16 insertions(+) diff --git a/python/paddle/hapi/progressbar.py b/python/paddle/hapi/progressbar.py index 6ed33f4f960..8020029be2a 100644 --- a/python/paddle/hapi/progressbar.py +++ b/python/paddle/hapi/progressbar.py @@ -20,6 +20,7 @@ import os import sys import time import numpy as np +import struct from collections import namedtuple __all__ = [] @@ -79,6 +80,20 @@ class ProgressBar(object): def update(self, current_num, values={}): now = time.time() + def convert_uint16_to_float(in_list): + in_list = np.asarray(in_list) + out = np.vectorize( + lambda x: struct.unpack('