提交 a249c0ca 编写于 作者: Y yangyaming

Refine doc and fix dtype.

上级 8314412b
...@@ -2719,22 +2719,22 @@ def multiplex(inputs, index): ...@@ -2719,22 +2719,22 @@ def multiplex(inputs, index):
input variables and let :math:`I_i` represents the i-th input variable and i input variables and let :math:`I_i` represents the i-th input variable and i
is in [0, :math:`m`). All input variables are tensors with same shape is in [0, :math:`m`). All input variables are tensors with same shape
[:math:`d_0`, :math:`d_1`, ..., :math:`d_R`]. Please note that rank of the [:math:`d_0`, :math:`d_1`, ..., :math:`d_R`]. Please note that rank of the
input tensor should be at least 2. Each input variable will be viewed as a input tensor should be at least 2. Each input variable will be treated as a
2-D matrix with shape [:math:`M`, :math:`N`] where :math:`M` for :math:`d_0` 2-D matrix with shape [:math:`M`, :math:`N`] where :math:`M` for :math:`d_0`
and :math:`N` for :math:`d_1` * :math:`d_2` * ... * :math:`d_R`. Let and :math:`N` for :math:`d_1` * :math:`d_2` * ... * :math:`d_R`. Let
:math:`I_i[j]` be the j-th row of the i-th input variable. The given index :math:`I_i[j]` be the j-th row of the i-th input variable. The given index
variable should be a 2-D tensor with shape [:math:`M`, 1]. Let `ID[i]` be variable should be a 2-D tensor with shape [:math:`M`, 1]. Let `ID[i]` be
the i-th index value of index variable. Then the output variable will be a the i-th index value of the index variable. Then the output variable will
tensor with shape [:math:`d_0`, :math:`d_1`, ..., :math:`d_R`]. If we view be a tensor with shape [:math:`d_0`, :math:`d_1`, ..., :math:`d_R`]. If we
the output tensor as a 2-D matrix with shape [:math:`M`, :math:`N`] and let treat the output tensor as a 2-D matrix with shape [:math:`M`, :math:`N`]
:math:`O[i]` be the i-th row of the matrix, then values of `O[i]` come from and let :math:`O[i]` be the i-th row of the matrix, then `O[i]` is equal to
:math:`I_{ID[i]}[i]`. :math:`I_{ID[i]}[i]`.
Args: Args:
inputs (list): Input variables which are tensors with same shape and the inputs (list): A list of variables to gather from. All variables have the
rank is at least 2. same shape and the rank is at least 2.
index (Variable): Tensor<int32>, index variable which is a 2-D tensor index (Variable): Tensor<int32>, index variable which is a 2-D tensor
with shape [M, 1] where M for batch size. with shape [M, 1] where M is the batch size.
Returns: Returns:
Variable: Multiplex variable gathered from input variables. Variable: Multiplex variable gathered from input variables.
...@@ -2748,7 +2748,12 @@ def multiplex(inputs, index): ...@@ -2748,7 +2748,12 @@ def multiplex(inputs, index):
out = fluid.layers.multiplex(inputs=[x1, x2], index=index) out = fluid.layers.multiplex(inputs=[x1, x2], index=index)
""" """
helper = LayerHelper('multiplex', **locals()) helper = LayerHelper('multiplex', **locals())
out = helper.create_tmp_variable(helper.input_dtype())
if not isinstance(inputs, list) and len(inputs) < 2:
raise ValueError("inputs should be a list object and contains at least "
"2 elements.")
out = helper.create_tmp_variable(inputs[0].dtype)
helper.append_op( helper.append_op(
type='multiplex', type='multiplex',
inputs={'X': inputs, inputs={'X': inputs,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册