merge_selected_rows

paddle.fluid.layers.nn. merge_selected_rows ( x, name=None ) [source]

MergeSelectedRows Operator.

MergeSelectedRows is used to merge the duplicated rows of the input. The output’s row has no duplicated, and it’s order is incremental.

Example: Input: X.rows is [0, 5, 5, 4, 19] X.height is 20 X.value is: [[1, 1] [2, 2] [3, 3] [4, 4] [6, 6]]

Output: Out.row is [0, 4, 5, 19] Out.height is 20 Out.value is: [[1, 1] [4, 4] [5, 5] [6, 6]]

Parameters
  • x (Variable) – The input type is SelectedRows, and the selected rows may be duplicated

  • name (basestring|None) – Name of the output.

Returns

The output type is SelectedRows, and the selected rows are not duplicated

Return type

out(Variable)

Examples

import paddle.fluid as fluid
b = fluid.default_main_program().global_block()
var = b.create_var(
    name="X", dtype="float32", persistable=True,
    type=fluid.core.VarDesc.VarType.SELECTED_ROWS)
y = fluid.layers.merge_selected_rows(var)