From 036f81fce9d4f732f62ec270101c87fea9882ad0 Mon Sep 17 00:00:00 2001 From: JZ-LIANG <38102074+JZ-LIANG@users.noreply.github.com> Date: Tue, 15 Jun 2021 18:13:47 +0800 Subject: [PATCH] bugfix: param init with fill constant str_value (#33381) (#33472) --- 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