Local Response Normalization Layer. This layer performs a type of
This operator implements the Local Response Normalization Layer.
"lateral inhibition" by normalizing over local input regions.
This layer performs a type of "lateral inhibition" by normalizing over local input regions.
For more information, please refer to `ImageNet Classification with Deep Convolutional Neural Networks <https://papers.nips.cc/paper/4824-imagenet-classification-with-deep-convolutional-neural-networks.pdf>`_
input (Variable): The input tensor of this layer, and the dimension of input tensor must be 4.
input (Variable): Input feature, 4D-Tensor with the shape of [N,C,H,W], where N is the batch size, C is the input channel, H is Height, W is weight. The data type is float32. The rank of this tensor must be 4, otherwise it will raise ValueError.
n (int, default 5): The number of channels to sum over.
n (int, optional): The number of channels to sum over. Default: 5
k (float, default 1.0): An offset (usually positive to avoid dividing by 0).
k (float, optional): An offset, positive. Default: 1.0
alpha (float, default 1e-4): The scaling parameter.
alpha (float, optional): The scaling parameter, positive. Default:1e-4
beta (float, default 0.75): The exponent.
beta (float, optional): The exponent, positive. Default:0.75
name (str, default None): A name for this operation.
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`
Raises:
ValueError: If rank of the input tensor is not 4.
Returns:
Returns:
A tensor variable storing the transformation result.
Variable: A tensor variable storing the transformation result with the same shape and data type as input.
Region of interest pooling (also known as RoI pooling) is to perform max pooling on inputs of nonuniform sizes to obtain fixed-size feature maps (e.g. 7*7).
The operator has three steps:
1. Dividing each region proposal into equal-sized sections with the pooled_width and pooled_height;
2. Finding the largest value in each section;
3. Copying these max values to the output buffer.
For more information, please refer to https://stackoverflow.com/questions/43430056/what-is-roi-layer-in-fast-rcnn
Args:
Args:
input (Variable): ${x_comment}
input (Variable): Input feature, 4D-Tensor with the shape of [N,C,H,W], where N is the batch size, C is the input channel, H is Height, W is weight. The data type is float32 or float64.
rois (Variable): ROIs (Regions of Interest) to pool over.It should be
rois (Variable): ROIs (Regions of Interest) to pool over. 2D-LoDTensor with the shape of [num_rois,4], the lod level is 1. Given as [[x1, y1, x2, y2], ...], (x1, y1) is the top left coordinates, and (x2, y2) is the bottom right coordinates.
a 2-D LoDTensor of shape (num_rois, 4), the lod level
pooled_height (int, optional): The pooled output height, data type is int32. Default: 1
is 1. Given as [[x1, y1, x2, y2], ...], (x1, y1) is
pooled_width (int, optional): The pooled output height, data type is int32. Default: 1
the top left coordinates, and (x2, y2) is the bottom
spatial_scale (float, optional): Multiplicative spatial scale factor to translate ROI coords from their input scale to the scale used when pooling. Default: 1.0
input (Variable): This input is a probability computed by the previous operator.
input (Variable): Predicted data, 2D-Tensor with the shape of [batch_size, 1]. The data type should be float32 or float64.
The first dimension is batch size, and the last dimension is 1.
label (Variable): Ground truth label, 2D-Tensor with the shape of [batch_size, 1]. The data type should be float32 or float64.
label (Variable): The groud truth whose first dimension is batch size
delta (float): The threshold for Huber loss, which is used to control the balance between the linear error and square error. The data type should be float32.
and last dimension is 1.
delta (float): The parameter of huber loss, which controls
the range of outliers
Returns:
Returns:
huber\_loss (Variable): The huber loss with shape [batch_size, 1].
Variable: The huber loss, a tensor with the same shape and data type as input.
Examples:
Examples:
.. code-block:: python
.. code-block:: python
import paddle.fluid as fluid
import paddle.fluid as fluid
import numpy as np
x = fluid.layers.data(name='x', shape=[13], dtype='float32')
This operator implements the hard_swish activation function.
Hard_swish is proposed in MobileNetV3, and performs better in computational stability and efficiency compared to swish function.
For more details please refer to: https://arxiv.org/pdf/1905.02244.pdf
The formula is as follows:
.. math::
out = \\frac{x * (min(max(0, x+offset), threshold))}{scale}
In the above equation:
``threshold`` and ``scale`` should be positive, ``offset`` can be positive or negative. It is recommended to use default parameters.
Args:
Args:
x(Varaible): Input of HardSwish operator.
x (Variable): Input feature, multi-dimensional Tensor. The data type should be float32 or float64.
threshold(float): The threshold parameter of HardSwish operator. Default:threshold=6.0
threshold (float, optional): The threshold in Relu function. Default: 6.0
scale(float): The scale parameter of HardSwish operator. Default:scale=6.0
scale (float, optional): The scale factor. Default: 6.0
offset(float): The offset parameter of HardSwish operator. Default:offset=3.0
offset (float, optional): The offset factor. Default: 3.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:
Variable: The output tensor with the same shape as input.
Variable: The output tensor with the same shape and data type as input.
Examples:
Examples:
.. code-block:: python
.. code-block:: python
import paddle.fluid as fluid
import paddle.fluid as fluid
x = fluid.layers.data(name="x", shape=[3,10,32,32], dtype="float32")
import numpy as np
DATATYPE='float32'
x_data = np.array([i for i in range(1,5)]).reshape([1,1,4]).astype(DATATYPE)
x = fluid.data(name="x", shape=[None,1,4], dtype=DATATYPE)