From 697f92ef86d3079fd82ec2fb9b8dc52fb8ef462a Mon Sep 17 00:00:00 2001 From: fengjiayi Date: Fri, 12 Jan 2018 15:36:47 +0800 Subject: [PATCH] Add type check --- python/paddle/v2/fluid/clip.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/python/paddle/v2/fluid/clip.py b/python/paddle/v2/fluid/clip.py index 6ed97cbe6..3dccd74bd 100644 --- a/python/paddle/v2/fluid/clip.py +++ b/python/paddle/v2/fluid/clip.py @@ -40,6 +40,11 @@ def error_clip_callback(block, context): op_desc.output_arg_names()): fwd_var = block.var_recursive(grad_to_var[grad_n]) error_clip = getattr(fwd_var, "error_clip", None) + if not (error_clip is None or isinstance(error_clip, + BaseErrorClipAttr)): + raise TypeError( + "Variable's error_clip should be an instance of BaseErrorClipAttr or None." + ) if error_clip is not None: error_clip.append_clip_op(block, grad_n) -- GitLab