From 6d3b030bb51a9179c619449adb36d88ef3984fd3 Mon Sep 17 00:00:00 2001 From: guosheng Date: Mon, 22 Oct 2018 11:01:34 +0800 Subject: [PATCH] Refine the api of reshape to be compatible. test=develop --- paddle/fluid/API.spec | 2 +- python/paddle/fluid/layers/nn.py | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/paddle/fluid/API.spec b/paddle/fluid/API.spec index e3776762f9..ec9142508d 100644 --- a/paddle/fluid/API.spec +++ b/paddle/fluid/API.spec @@ -107,7 +107,7 @@ paddle.fluid.layers.softmax_with_cross_entropy ArgSpec(args=['logits', 'label', paddle.fluid.layers.smooth_l1 ArgSpec(args=['x', 'y', 'inside_weight', 'outside_weight', 'sigma'], varargs=None, keywords=None, defaults=(None, None, None)) paddle.fluid.layers.one_hot ArgSpec(args=['input', 'depth'], varargs=None, keywords=None, defaults=None) paddle.fluid.layers.autoincreased_step_counter ArgSpec(args=['counter_name', 'begin', 'step'], varargs=None, keywords=None, defaults=(None, 1, 1)) -paddle.fluid.layers.reshape ArgSpec(args=['x', 'shape', 'actual_shape', 'inplace', 'name'], varargs=None, keywords=None, defaults=(None, False, None)) +paddle.fluid.layers.reshape ArgSpec(args=['x', 'shape', 'actual_shape', 'act', 'inplace', 'name'], varargs=None, keywords=None, defaults=(None, None, False, None)) paddle.fluid.layers.squeeze ArgSpec(args=['input', 'axes', 'name'], varargs=None, keywords=None, defaults=(None,)) paddle.fluid.layers.unsqueeze ArgSpec(args=['input', 'axes', 'name'], varargs=None, keywords=None, defaults=(None,)) paddle.fluid.layers.lod_reset ArgSpec(args=['x', 'y', 'target_lod'], varargs=None, keywords=None, defaults=(None, None)) diff --git a/python/paddle/fluid/layers/nn.py b/python/paddle/fluid/layers/nn.py index 3ce0126c83..019f981ccf 100644 --- a/python/paddle/fluid/layers/nn.py +++ b/python/paddle/fluid/layers/nn.py @@ -4830,7 +4830,7 @@ def autoincreased_step_counter(counter_name=None, begin=1, step=1): return counter -def reshape(x, shape, actual_shape=None, inplace=False, name=None): +def reshape(x, shape, actual_shape=None, act=None, inplace=False, name=None): """ Gives a new shape to the input Tensor without changing its data. @@ -4878,9 +4878,11 @@ def reshape(x, shape, actual_shape=None, inplace=False, name=None): :attr:`shape` specifying shape. That is to say :attr:`actual_shape` has a higher priority than :attr:`shape`. - inplace(bool): If this flag is set true, reuse the input :attr:`x` as - output, which will change the shape of variable :attr:`x`. - Otherwise, preserve the shape :attr:`x` and return a new + act (str): The non-linear activation to be applied to the reshaped tensor + variable. + inplace(bool): If this flag is set true, reuse input :attr:`x` to reshape, + which will change the shape of tensor variable :attr:`x`. + Otherwise, preserve the shape :attr:`x` and create a new output tensor variable whose data is copied from input x but reshaped. Though setting to :attr:`True` will be more efficient, :attr:`False` is suggested when :attr:`x` are @@ -4936,7 +4938,7 @@ def reshape(x, shape, actual_shape=None, inplace=False, name=None): outputs={"Out": out, "XShape": x_shape}) - return out + return helper.append_activation(out) def squeeze(input, axes, name=None): -- GitLab