diff --git a/paddle/fluid/API.spec b/paddle/fluid/API.spec index 032da0cad85ce43ab2630123f9f2cfd8dee4224e..69813b3eebe57165eede8bc3aa9864439c7d5414 100644 --- a/paddle/fluid/API.spec +++ b/paddle/fluid/API.spec @@ -134,7 +134,7 @@ paddle.fluid.layers.sampled_softmax_with_cross_entropy (ArgSpec(args=['logits', paddle.fluid.layers.hsigmoid (ArgSpec(args=['input', 'label', 'num_classes', 'param_attr', 'bias_attr', 'name', 'path_table', 'path_code', 'is_custom', 'is_sparse'], varargs=None, keywords=None, defaults=(None, None, None, None, None, False, False)), ('document', '80641ee6810b1cdc3fd6e14fc89ecc9d')) paddle.fluid.layers.beam_search (ArgSpec(args=['pre_ids', 'pre_scores', 'ids', 'scores', 'beam_size', 'end_id', 'level', 'is_accumulated', 'name', 'return_parent_idx'], varargs=None, keywords=None, defaults=(0, True, None, False)), ('document', 'b350b9a30a18e7efd7e1bb740eef6996')) paddle.fluid.layers.row_conv (ArgSpec(args=['input', 'future_context_size', 'param_attr', 'act'], varargs=None, keywords=None, defaults=(None, None)), ('document', '17485788fffe4e2d36dc58c2ac8d174e')) -paddle.fluid.layers.multiplex (ArgSpec(args=['inputs', 'index'], varargs=None, keywords=None, defaults=None), ('document', '013795af319e2e86d3506741941078ee')) +paddle.fluid.layers.multiplex (ArgSpec(args=['inputs', 'index'], varargs=None, keywords=None, defaults=None), ('document', '2c4d1ae83da6ed35e3b36ba1b3b51d23')) paddle.fluid.layers.layer_norm (ArgSpec(args=['input', 'scale', 'shift', 'begin_norm_axis', 'epsilon', 'param_attr', 'bias_attr', 'act', 'name'], varargs=None, keywords=None, defaults=(True, True, 1, 1e-05, None, None, None, None)), ('document', 'de6a906950bae9f3c245cb744d22b94e')) paddle.fluid.layers.group_norm (ArgSpec(args=['input', 'groups', 'epsilon', 'param_attr', 'bias_attr', 'act', 'data_layout', 'name'], varargs=None, keywords=None, defaults=(1e-05, None, None, None, 'NCHW', None)), ('document', '419c3a24a83cc89219a029cf4092788b')) paddle.fluid.layers.spectral_norm (ArgSpec(args=['weight', 'dim', 'power_iters', 'eps', 'name'], varargs=None, keywords=None, defaults=(0, 1, 1e-12, None)), ('document', '3f536aafba30d793287b52d231baff1b')) diff --git a/python/paddle/fluid/layers/nn.py b/python/paddle/fluid/layers/nn.py index c4e6053fec0514479ec4b0c110dfaf4610e677f5..c0bc005ee020fdfb62e12d7c17407d5d7643b3c1 100644 --- a/python/paddle/fluid/layers/nn.py +++ b/python/paddle/fluid/layers/nn.py @@ -5866,11 +5866,49 @@ def multiplex(inputs, index): """ ${comment} - >>> import paddle.fluid as fluid - >>> x1 = fluid.layers.data(name='x1', shape=[4], dtype='float32') - >>> x2 = fluid.layers.data(name='x2', shape=[4], dtype='float32') - >>> index = fluid.layers.data(name='index', shape=[1], dtype='int32') - >>> out = fluid.layers.multiplex(inputs=[x1, x2], index=index) + For Example: + + .. code-block:: text + + case 1: + + Given: + + X = [[[0,0,3,4], [0,1,3,4], [0,2,4,4], [0,3,3,4]], + [[1,0,3,4], [1,1,7,8], [1,2,4,2], [1,3,3,4]], + [[2,0,3,4], [2,1,7,8], [2,2,4,2], [2,3,3,4]], + [[3,0,3,4], [3,1,7,8], [3,2,4,2], [3,3,3,4]]] + + index = [3,0,1,2] + + out:[[3 0 3 4] // X[3,0] (3 = index[i], 0 = i); i=0 + [0 1 3 4] // X[0,1] (0 = index[i], 1 = i); i=1 + [1 2 4 2] // X[1,2] (0 = index[i], 2 = i); i=2 + [2 3 3 4]] // X[2,3] (0 = index[i], 3 = i); i=3 + + case 2: + + Given: + + X = [[[0,0,3,4], [0,1,3,4], [0,2,4,4], [0,3,3,4]], + [[1,0,3,4], [1,1,7,8], [1,2,4,2], [1,3,3,4]]] + + index = [1,0] + + out:[[1 0 3 4] // X[1,0] (3 = index[0], 0 = i); i=1 + [0 1 3 4] // X[0,1] (0 = index[1], 1 = i); i=2 + [0 2 4 4] // X[0,2] (0 = 0, 2 = i); i=3 + [0 3 3 4]] // X[0,3] (0 = 0, 3 = i); i=4 + + Examples: + + .. code-block:: python + + import paddle.fluid as fluid + x1 = fluid.layers.data(name='x1', shape=[4], dtype='float32') + x2 = fluid.layers.data(name='x2', shape=[4], dtype='float32') + index = fluid.layers.data(name='index', shape=[1], dtype='int32') + out = fluid.layers.multiplex(inputs=[x1, x2], index=index) Args: inputs (list): ${x_comment}.