Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add python wrapper for multiplex operator. #7739

Merged
merged 7 commits into from
Jan 25, 2018

Conversation

pkuyym
Copy link
Contributor

@pkuyym pkuyym commented Jan 22, 2018

Resolves #7717

@pkuyym pkuyym requested a review from kuke January 22, 2018 13:13
… fix-7717

Conflicts:
	doc/api/v2/fluid/layers.rst
	python/paddle/v2/fluid/layers/nn.py
	python/paddle/v2/fluid/tests/test_layers.py
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
[: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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

viewed -> treated

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

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
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the i-th index value of index variable -> the i-th index of the index variable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

: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
the i-th index value of index variable. Then the output variable will be a
tensor with shape [:math:`d_0`, :math:`d_1`, ..., :math:`d_R`]. If we view
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

view -> treat

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

the i-th index value of index variable. Then the output variable will be a
tensor with shape [:math:`d_0`, :math:`d_1`, ..., :math:`d_R`]. If we view
the output tensor as a 2-D matrix with shape [:math:`M`, :math:`N`] and let
:math:`O[i]` be the i-th row of the matrix, then values of `O[i]` come from
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then values of O[i] come from -> then O[i] is equal to

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Thanks.

:math:`I_{ID[i]}[i]`.

Args:
inputs (list): Input variables which are tensors with same shape and the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Input variables which are tensors with same shape -> A variable list in which every variable has the same shape

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

inputs (list): Input variables which are tensors with same shape and the
rank is at least 2.
index (Variable): Tensor<int32>, index variable which is a 2-D tensor
with shape [M, 1] where M for batch size.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where M for batch size -> where M is the batch size

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Contributor

@kuke kuke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two more fixes


Referring to the given index variable, this layer gathers from the input
variables to output a multiplex variable. Assuming that there are :math:`m`
input variables and let :math:`I_i` represents the i-th input variable and i
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

represents->represent or delete let

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

"""
**Multiplex Layer**

Referring to the given index variable, this layer gathers from the input
Copy link
Contributor

@kuke kuke Jan 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this layer gathers from the input variables to output a multiplex variable -> this layer fetches rows from the input variables and constructs a multiplex variable for output

gather is not a suitable word.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, done.

Copy link
Contributor

@kuke kuke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@pkuyym pkuyym merged commit 7278aa7 into PaddlePaddle:develop Jan 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants