khatri_rao#

ivy.khatri_rao(x, weights=None, skip_matrix=None, mask=None, out=None)[source]#

Khatri-Rao product of a sequence of matrices.

This can be seen as a column-wise kronecker product. If one matrix only is given, that matrix is directly returned.

Parameters:
  • x (Sequence[Union[Array, NativeArray]]) –

    Sequence of tensors with the same number of columns, i.e.::
    for i in len(x):

    x[i].shape = (n_i, m)

  • weights (Optional[Union[Array, NativeArray]], default: None) – array of weights for each rank, of length m, the number of column of the factors (i.e. m == factor[i].shape[1] for any factor)

  • skip_matrix (Optional[Sequence[int]], default: None) – if not None, index of a matrix to skip

  • mask (Optional[Union[Array, NativeArray]], default: None) – array of 1s and 0s of length m

  • out (Optional[Array], default: None) – optional output array, for writing the result to. It must have a shape that the result can broadcast to.

Return type:

Array

Returns:

khatri_rao_product (ivy.Array of shape (prod(n_i), m)) – where prod(n_i) = prod([m.shape[0] for m in input]) i.e. the product of the number of rows of all the input in the product.