Skip to content

Commit d4f63d8

Browse files
authored
Merge pull request #16475 from junjun315/fix-doc-multiplex
refine multiplex-doc
2 parents de605cc + 3f8b2f5 commit d4f63d8

File tree

2 files changed

+44
-6
lines changed

2 files changed

+44
-6
lines changed

paddle/fluid/API.spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ paddle.fluid.layers.sampled_softmax_with_cross_entropy (ArgSpec(args=['logits',
134134
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'))
135135
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'))
136136
paddle.fluid.layers.row_conv (ArgSpec(args=['input', 'future_context_size', 'param_attr', 'act'], varargs=None, keywords=None, defaults=(None, None)), ('document', '17485788fffe4e2d36dc58c2ac8d174e'))
137-
paddle.fluid.layers.multiplex (ArgSpec(args=['inputs', 'index'], varargs=None, keywords=None, defaults=None), ('document', '013795af319e2e86d3506741941078ee'))
137+
paddle.fluid.layers.multiplex (ArgSpec(args=['inputs', 'index'], varargs=None, keywords=None, defaults=None), ('document', '2c4d1ae83da6ed35e3b36ba1b3b51d23'))
138138
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'))
139139
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'))
140140
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'))

python/paddle/fluid/layers/nn.py

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5867,11 +5867,49 @@ def multiplex(inputs, index):
58675867
"""
58685868
${comment}
58695869
5870-
>>> import paddle.fluid as fluid
5871-
>>> x1 = fluid.layers.data(name='x1', shape=[4], dtype='float32')
5872-
>>> x2 = fluid.layers.data(name='x2', shape=[4], dtype='float32')
5873-
>>> index = fluid.layers.data(name='index', shape=[1], dtype='int32')
5874-
>>> out = fluid.layers.multiplex(inputs=[x1, x2], index=index)
5870+
For Example:
5871+
5872+
.. code-block:: text
5873+
5874+
case 1:
5875+
5876+
Given:
5877+
5878+
X = [[[0,0,3,4], [0,1,3,4], [0,2,4,4], [0,3,3,4]],
5879+
[[1,0,3,4], [1,1,7,8], [1,2,4,2], [1,3,3,4]],
5880+
[[2,0,3,4], [2,1,7,8], [2,2,4,2], [2,3,3,4]],
5881+
[[3,0,3,4], [3,1,7,8], [3,2,4,2], [3,3,3,4]]]
5882+
5883+
index = [3,0,1,2]
5884+
5885+
out:[[3 0 3 4] // X[3,0] (3 = index[i], 0 = i); i=0
5886+
[0 1 3 4] // X[0,1] (0 = index[i], 1 = i); i=1
5887+
[1 2 4 2] // X[1,2] (0 = index[i], 2 = i); i=2
5888+
[2 3 3 4]] // X[2,3] (0 = index[i], 3 = i); i=3
5889+
5890+
case 2:
5891+
5892+
Given:
5893+
5894+
X = [[[0,0,3,4], [0,1,3,4], [0,2,4,4], [0,3,3,4]],
5895+
[[1,0,3,4], [1,1,7,8], [1,2,4,2], [1,3,3,4]]]
5896+
5897+
index = [1,0]
5898+
5899+
out:[[1 0 3 4] // X[1,0] (3 = index[0], 0 = i); i=1
5900+
[0 1 3 4] // X[0,1] (0 = index[1], 1 = i); i=2
5901+
[0 2 4 4] // X[0,2] (0 = 0, 2 = i); i=3
5902+
[0 3 3 4]] // X[0,3] (0 = 0, 3 = i); i=4
5903+
5904+
Examples:
5905+
5906+
.. code-block:: python
5907+
5908+
import paddle.fluid as fluid
5909+
x1 = fluid.layers.data(name='x1', shape=[4], dtype='float32')
5910+
x2 = fluid.layers.data(name='x2', shape=[4], dtype='float32')
5911+
index = fluid.layers.data(name='index', shape=[1], dtype='int32')
5912+
out = fluid.layers.multiplex(inputs=[x1, x2], index=index)
58755913
58765914
Args:
58775915
inputs (list): ${x_comment}.

0 commit comments

Comments
 (0)