besides -1, 0 means the actual dimension value is going to be copied from
besides -1, 0 means the actual dimension value is going to be copied from
the corresponding dimension of x.
the corresponding dimension of x.
**Warning:** the parameter :attr:`actual_shape` will be deprecated in the future and only use :attr:`shape` instead.
**Note**:
The parameter ``actual_shape`` will be deprecated in the future and only use ``shape`` instead to represent the target shape.
Args:
Args:
x(variable): The input tensor.
x(Variable): A ``Tensor`` or ``LoDTensor`` . The data type is ``float32``, ``float64``, ``int32`` or ``int64``.
shape(list|tuple|Variable): The new shape. At most one dimension of the new shape can
shape(list|tuple|Variable): Define the target shape. At most one dimension of the target shape can be -1.
be -1. If :attr:`shape` is a list or tuple, it can contain Variable or not and
The data type is ``int32`` . If ``shape`` is a list or tuple, the elements of it should be integers or Tensors with shape [1].
the shape of Variable must be [1].
If ``shape`` is an Variable, it should be an 1-D Tensor .
actual_shape(variable, optional): An 1-D ``Tensor`` or ``LoDTensor`` . The data type is ``int32`` . If provided, reshape
actual_shape(variable): An optional input. If provided, reshape
according to this given shape rather than ``shape`` specifying shape.
according to this given shape rather than
That is to say ``actual_shape`` has a higher priority
:attr:`shape` specifying shape. That is to
than ``shape(list|tuple)`` but not ``shape(Variable)``. \
say :attr:`actual_shape` has a higher priority
This argument ``actual_shape`` will be removed in a future version. \
than :attr:`shape(list|tuple)` but not :attr:`shape(Variable)`. \
Instructions for updating: ``actual_shape`` will be removed in future versions and replaced by ``shape``.
This argument :attr:`actual_shape` will be removed in a future version. \
act (str, optional): The non-linear activation to be applied to the reshaped input. Default None.
Instructions for updating: :attr:`actual_shape` is deprecated,
inplace(bool, optional): If ``inplace`` is True, the input and output of ``layers.reshape``
only use :attr:`shape` instead.
are the same variable. Otherwise, the input and output of
act (str): The non-linear activation to be applied to the reshaped tensor
``layers.reshape`` are different variable. Default False. Note that if ``x``
variable.
is more than one OPs' input, ``inplace`` must be False.
inplace(bool): If ``inplace`` is `True`, the input and output of ``layers.reshape``
name(str, optional): The default value is None. Normally there is no need for user to set this property.
are the same variable, otherwise, the input and output of
For more information, please refer to :ref:`api_guide_Name` .
``layers.reshape`` are different variables. Note that if :attr:`x`
is more than one layer's input, ``inplace`` must be :attr:`False`.
name (str): The name of this layer. It is optional.
Returns:
Returns:
Variable: The reshaped tensor variable if :attr:`act` is None. It is a \
Variable: A ``Tensor`` or ``LoDTensor``. The data type is same as ``x``. It is a new tensor variable if ``inplace`` is ``False``, otherwise it is ``x``. If ``act`` is None, return the reshaped tensor variable, otherwise return the activated tensor variable.
new tensor variable if :attr:`inplace` is :attr:`False`, \
otherwise it is :attr:`x`. If :attr:`act` is not None, return \
the activated tensor variable.
Raises:
Raises:
TypeError: if actual_shape is neither Variable nor None.
TypeError: If actual_shape is neither Variable nor None.
ValueError: If more than one elements of ``shape`` is -1.
ValueError: If the element of ``shape`` is 0, the corresponding dimension should be less than or equal to the dimension of ``x``.
ValueError: If the elements in ``shape`` is negative except -1.
x(Variable): A ``Tensor`` or ``LoDTensor`` . The data type is ``float32`` or ``float64``.
factor(float|Variable|1.0): The exponential factor of Pow.
factor(float32|Variable, optional): A scalar with type ``float32`` or a ``Tensor`` with shape [1] and type ``float32``. The exponential factor of Pow. Default 1.0.
name(str|None): A name for this layer(optional). If set None, the layer
name(str, optional): The default value is None. Normally there is no need for user to set this property. For more information, please refer to :ref:`api_guide_Name` .
will be named automatically.
Returns:
Returns:
output(${out_type}): ${out_comment}
Variable: A ``Tensor`` or ``LoDTensor``. The data type is same as ``x``.
x (Variable): A ``Tensor`` or ``LoDTensor`` with dimension in [1, 6]. The data type is ``bool``, ``float32``, ``float64`` or ``int32`` .
expand_times (list|tuple|Variable): Expand times number for each dimension.
expand_times (list|tuple|Variable): The data type is ``int32`` . If ``expand_times`` is a list or tuple, the elements of
it should be integers or Tensors with shape [1]. If ``expand_times`` is an Variable, it should be an 1-D Tensor.
Expand times number for each dimension of ``x`` .
name (str, optional): The default value is None. Normally there is no need for user to set this property. For more information, please refer to :ref:`api_guide_Name` .
Returns:
Returns:
Variable: The expanded variable which is a LoDTensor. After expanding, size of each dimension of Output(Out) is equal to ithe size of the corresponding dimension of Input(X) multiplying the corresponding value given by expand_times.
Variable: A ``Tensor`` or ``LoDTensor``. The data type is same as ``x``. After expanding, size of each dimension of output is equal to the size of the corresponding dimension of ``x`` multiplying the corresponding value given by ``expand_times`` .
Raises:
TypeError: The type of ``expand_times`` must be list, tuple or Variable.
ValueError: The elements of ``expand_times`` cannot be negative.