From f249a5f05f0f5832279244d88c8cb4eaaad1fbd4 Mon Sep 17 00:00:00 2001 From: JZ-LIANG <38102074+JZ-LIANG@users.noreply.github.com> Date: Wed, 9 Jun 2021 20:32:20 +0800 Subject: [PATCH] bugfix: param init with fill constant str_value (#33381) --- python/paddle/fluid/initializer.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/python/paddle/fluid/initializer.py b/python/paddle/fluid/initializer.py index 5b2010f3409..54ba5f22e53 100644 --- a/python/paddle/fluid/initializer.py +++ b/python/paddle/fluid/initializer.py @@ -152,6 +152,7 @@ class ConstantInitializer(Initializer): out_dtype = var.dtype out_var = var + # fill constant should set the "str_value" to preserve precision op = block.append_op( type="fill_constant", outputs={"Out": out_var}, @@ -159,6 +160,7 @@ class ConstantInitializer(Initializer): "shape": var.shape, "dtype": int(out_dtype), "value": float(self._value), + 'str_value': str(float(self._value)), 'force_cpu': self._force_cpu }, stop_gradient=True) -- GitLab