From ee36f15b9013673b88336fb1626e920b20263271 Mon Sep 17 00:00:00 2001 From: LI Yunxiang <39279048+Banmahhhh@users.noreply.github.com> Date: Fri, 15 Nov 2019 12:35:57 +0800 Subject: [PATCH] Update common.py (#173) --- parl/core/fluid/plutils/common.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/parl/core/fluid/plutils/common.py b/parl/core/fluid/plutils/common.py index c55173c..8f518fc 100644 --- a/parl/core/fluid/plutils/common.py +++ b/parl/core/fluid/plutils/common.py @@ -35,6 +35,10 @@ def fetch_framework_var(attr_name): scope = fluid.executor.global_scope() core_var = scope.find_var(attr_name) + if core_var == None: + raise KeyError( + "Unable to find the variable:{}. Synchronize paramsters before initialization or attr_name does not exist." + .format(attr_name)) shape = core_var.get_tensor().shape() framework_var = fluid.layers.create_parameter( shape=shape, dtype='float32', attr=fluid.ParamAttr(name=attr_name)) -- GitLab