kron¶
- paddle. kron ( x, y, name=None ) [source]
-
Kron Operator.
This operator computes the Kronecker product of two tensors, a composite tensor made of blocks of the second tensor scaled by the first.
This operator assumes that the rank of the two tensors, X and Y are the same, if necessary prepending the smallest with ones. If the shape of X is [r0, r1, …, rN] and the shape of Y is [s0, s1, …, sN], then the shape of the output tensor is [r0s0, r1s1, …, rNsN]. The elements are products of elements from X and Y.
The equation is: output[k0,k1,…,kN]=X[i0,i1,…,iN]∗Y[j0,j1,…,jN]
where kt=it∗st+jt,t=0,1,…,N
- Args:
-
- x (Tensor): the fist operand of kron op, data type: float16, float32,
-
float64, int32 or int64.
- y (Tensor): the second operand of kron op, data type: float16,
-
float32, float64, int32 or int64. Its data type should be the same with x.
- name(str, optional): The default value is None. Normally there is no
-
need for user to set this property. For more information, please refer to Name.
- Returns:
-
Tensor: The output of kron op, data type: float16, float32, float64, int32 or int64. Its data is the same with x.
- Examples:
-
import paddle x = paddle.to_tensor([[1, 2], [3, 4]], dtype='int64') y = paddle.to_tensor([[1, 2, 3], [4, 5, 6], [7, 8, 9]], dtype='int64') out = paddle.kron(x, y) print(out) # [[1, 2, 3, 2, 4, 6], # [ 4, 5, 6, 8, 10, 12], # [ 7, 8, 9, 14, 16, 18], # [ 3, 6, 9, 4, 8, 12], # [12, 15, 18, 16, 20, 24], # [21, 24, 27, 28, 32, 36]])