bmm

paddle.fluid.layers.bmm(x, y, name=None)[source]

Applies batched matrix multiplication to two tensors. Both of the two input tensors must be three-dementional and share the same batch size. if x is a (b, m, k) tensor, y is a (b, k, n) tensor, the output will be a (b, m, n) tensor. :param x: The input variable which is a Tensor or LoDTensor. :type x: Variable :param y: The input variable which is a Tensor or LoDTensor. :type y: Variable :param name: A name for this layer(optional). If set None, the layer

System Message: ERROR/3 (/usr/local/lib/python2.7/dist-packages/paddle/fluid/layers/nn.py:docstring of paddle.fluid.layers.bmm, line 9)

Unexpected indentation.

will be named automatically.

System Message: WARNING/2 (/usr/local/lib/python2.7/dist-packages/paddle/fluid/layers/nn.py:docstring of paddle.fluid.layers.bmm, line 10)

Block quote ends without a blank line; unexpected unindent.

Returns

The product Tensor (or LoDTensor) variable.

Return type

Variable

Examples

import paddle import paddle.fluid as fluid x = fluid.layers.data(name=’x’, shape=[10, 3, 4], dtype=’float32’) y = fluid.layers.data(name=’y’, shape=[10, 4, 5], dtype=’float32’) out = fluid.layers.bmm(x, y)

# In dygraph mode: # size input1: (2, 2, 3) and input2: (2, 3, 2) input1 = np.array([[[1.0, 1.0, 1.0],[2.0, 2.0, 2.0]],[[3.0, 3.0, 3.0],[4.0, 4.0, 4.0]]]) input2 = np.array([[[1.0, 1.0],[2.0, 2.0],[3.0, 3.0]],[[4.0, 4.0],[5.0, 5.0],[6.0, 6.0]]]) with fluid.dygraph.guard():

System Message: ERROR/3 (/usr/local/lib/python2.7/dist-packages/paddle/fluid/layers/nn.py:docstring of paddle.fluid.layers.bmm, line 28)

Unexpected indentation.

x = fluid.dygraph.to_variable(input1) y = fluid.dygraph.to_variable(input2) out = fluid.layers.bmm(x, y) #output size: (2, 2, 2) #output value: #[[[6.0, 6.0],[12.0, 12.0]],[[45.0, 45.0],[60.0, 60.0]]] out_np = out.numpy()