Skip to content

Commit 319618e

Browse files
committed
optimize comment, add unit test test=develop
1 parent 53781fc commit 319618e

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

python/paddle/fluid/layers/nn.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8063,13 +8063,13 @@ def bilinear_tensor_product(x,
80638063
For example:
80648064
80658065
.. math::
8066-
y_{i} = x * W_{i} * {y^\mathrm{T}}, i=0,1,...,K-1
8066+
out{i} = x * W_{i} * {y^\mathrm{T}}, i=0,1,...,size-1
80678067
80688068
In this formular:
8069-
- :math:`x`: the first input contains M elements.
8070-
- :math:`y`: the second input contains N elements.
8071-
- :math:`y_{i}`: the i-th element of y.
8069+
- :math:`x`: the first input contains M elements, shape is [batch_size, M].
8070+
- :math:`y`: the second input contains N elements, shape is [batch_size, N].
80728071
- :math:`W_{i}`: the i-th learned weight, shape is [M, N]
8072+
- :math:`out{i}`: the i-th element of out, shape is [batch_size, size].
80738073
- :math:`y^\mathrm{T}`: the transpose of :math:`y_{2}`.
80748074
80758075
The simple usage is:
@@ -8079,8 +8079,8 @@ def bilinear_tensor_product(x,
80798079
tensor = bilinear_tensor_product(x=layer1, y=layer2, size=1000)
80808080
80818081
Args:
8082-
x (Variable): 3-D input tensor with shape [N x M x P]
8083-
y (Variable): 3-D input tensor with shape [N x M x P]
8082+
x (Variable): 2-D input tensor with shape [batch_size, M]
8083+
y (Variable): 2-D input tensor with shape [batch_size, N]
80848084
size (int): The dimension of this layer.
80858085
act (str, default None): Activation to be applied to the output of this layer.
80868086
name (str, default None): The name of this layer.

python/paddle/fluid/tests/unittests/test_layers.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,16 @@ def test_affine_grid(self):
901901
self.assertIsNotNone(data_1)
902902
print(str(program))
903903

904+
def test_bilinear_tensor_product_layer(self):
905+
program = Program()
906+
with program_guard(program):
907+
data = layers.data(name='data', shape=[4], dtype="float32")
908+
909+
theta = layers.data(name="theta", shape=[5], dtype="float32")
910+
out = layers.bilinear_tensor_product(data, theta, 6)
911+
912+
print(str(program))
913+
904914

905915
if __name__ == '__main__':
906916
unittest.main()

0 commit comments

Comments
 (0)