correlation

paddle.fluid.contrib.layers.nn. correlation ( x, y, pad_size, kernel_size, max_displacement, stride1, stride2, corr_type_multiply=1 ) [source]

This operation compute correlation of two tensor. For more information of correlation, please refer to PWC-Net: CNNs for Optical Flow Using Pyramid, Warping, and Cost Volume <https://arxiv.org/pdf/1709.02371.pdf>_

Parameters
  • x (Tensor) – The input x is 4-D Tensor with shape [N, C, H, W]. The data type is float32 and float64.

  • y (Tensor) – The input y is 4-D Tensor with shape [N, C, H, W]. The data type is float32 and float64.

  • pad_size (int) – Pad size. The data type is int.

  • max_displacement (int) – Max displacement. The data type is int.

  • stride1 (int) – stride size of x. The data type is int.

  • stride2 (int) – stride size of y. The data type is int.

  • corr_type_multiply (int, optional) – The type of multiply. The data type is int. Default: 1.

Returns

The data type is same as input tensor.

Return type

Tensor

Examples

import paddle.fluid as fluid

x1 = fluid.layers.data(name='x1',
                   shape=x_shape,
                   dtype=x_type,
                   append_batch_size=False)
x2 = fluid.layers.data(name='x2',
                    shape=x_shape,
                    dtype=x_type,
                    append_batch_size=False)


out = fluid.contrib.correlation(
                x1,
                x2,
                pad_size=4,
                kernel_size=1,
                max_displacement=4,
                stride1=1,
                stride2=1)