From cac3473b5aa1bdd2e78cb9311768447a9f6744e9 Mon Sep 17 00:00:00 2001 From: parap1uie-s Date: Thu, 19 Aug 2021 14:28:42 +0800 Subject: [PATCH] fix reshape when is a number --- 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 6251bdf165a97..d0d15e92bfb63 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)