diff --git a/python/paddle/fluid/dygraph/parallel.py b/python/paddle/fluid/dygraph/parallel.py index de761cad5298aa00e05c664fb98077d73622e692..344ae55ee9d453428093e5d0c7118447bd876189 100644 --- a/python/paddle/fluid/dygraph/parallel.py +++ b/python/paddle/fluid/dygraph/parallel.py @@ -416,7 +416,7 @@ class DataParallel(layers.Layer): g_var_shapes.append(g_var.shape) flattened_vars.append( nn.reshape( - x=g_var, shape=[np.prod(g_var.shape)], inplace=True)) + x=g_var, shape=[np.prod(g_var.shape)])) coalesced_grad = nn.concat(flattened_vars) coalesced_grads_and_grad_vars.append( [coalesced_grad, grad_vars, g_var_shapes]) diff --git a/python/paddle/fluid/layers/loss.py b/python/paddle/fluid/layers/loss.py index 037c7e850040f5097aa53b0499e3194aae4470a6..dce7494c1904e9b4c95a88bba5443aa88dc079c6 100644 --- a/python/paddle/fluid/layers/loss.py +++ b/python/paddle/fluid/layers/loss.py @@ -1755,7 +1755,7 @@ def npair_loss(anchor, positive, labels, l2_reg=0.002): Beta = 0.25 batch_size = labels.shape[0] - labels = nn.reshape(labels, shape=[batch_size, 1], inplace=True) + labels = nn.reshape(labels, shape=[batch_size, 1]) labels = nn.expand(labels, expand_times=[1, batch_size]) labels = equal(labels, nn.transpose(labels, perm=[1, 0])).astype('float32') diff --git a/python/paddle/fluid/layers/nn.py b/python/paddle/fluid/layers/nn.py index b5148c215e99faf0273f999c036d2e24272616b1..4a15ecb2004abcb64e9d12196bb5c7c031896d2f 100755 --- a/python/paddle/fluid/layers/nn.py +++ b/python/paddle/fluid/layers/nn.py @@ -6101,15 +6101,17 @@ def reshape(x, shape, actual_shape=None, act=None, inplace=False, name=None): Examples: .. code-block:: python - + + import paddle import paddle.fluid as fluid - + paddle.enable_static() + # example 1: # attr shape is a list which doesn't contain Tensors. data_1 = fluid.data( name='data_1', shape=[2, 4, 6], dtype='float32') reshaped_1 = fluid.layers.reshape( - x=data_1, shape=[-1, 0, 3, 2], inplace=True) + x=data_1, shape=[-1, 0, 3, 2]) # the shape of reshaped_1 is [2,4,3,2]. # example 2: diff --git a/python/paddle/tensor/manipulation.py b/python/paddle/tensor/manipulation.py index dc6a04a4723bd92dbe1c76fce5b3e52981136211..6345a01f14affcf88df633d972e6ac9d86fc2115 100644 --- a/python/paddle/tensor/manipulation.py +++ b/python/paddle/tensor/manipulation.py @@ -363,7 +363,7 @@ def roll(x, shifts, axis=None, name=None): outputs={'Out': out}, attrs={'axis': axis, 'shifts': shifts}) - out = layers.reshape(out, shape=origin_shape, inplace=True) + out = layers.reshape(out, shape=origin_shape) return out