From 866c1ea60b23b3aa2ebdb52d537bfadc56d03e4a Mon Sep 17 00:00:00 2001 From: parap1uie-s Date: Thu, 19 Aug 2021 19:10:59 +0800 Subject: [PATCH] fix reshape when is a number (#35016) --- python/paddle/fluid/layers/nn.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/python/paddle/fluid/layers/nn.py b/python/paddle/fluid/layers/nn.py index 6251bdf165a..d0d15e92bfb 100755 --- a/python/paddle/fluid/layers/nn.py +++ b/python/paddle/fluid/layers/nn.py @@ -6176,6 +6176,10 @@ def reshape(x, shape, actual_shape=None, act=None, inplace=False, name=None): elif isinstance(shape, Variable): shape.stop_gradient = True out, _ = _C_ops.reshape2(x, shape) + else: + raise ValueError( + "shape must be an instance of `list`, `tuple` or `Variable`," + " got '{}.'".format(type(shape))) return dygraph_utils._append_activation_in_dygraph(out, act) -- GitLab