YouTip LogoYouTip

Pytorch Torch Outer

# PyTorch torch.outer Function * * Pytorch torch Reference Manual](#) `torch.outer` is a function in PyTorch used to compute the outer product (also known as cross product or tensor product) of two vectors. The outer product multiplies each element in one vector with all elements in another vector, generating a matrix. ### Function Definition torch.outer(vec1, vec2, out) * * * ## Usage Example ## Example import torch # Define two vectors vec1 = torch.tensor([1,2,3]) vec2 = torch.tensor([4,5,6]) # Compute outer product result = torch.outer(vec1, vec2) print(result) Output result: tensor([[ 4, 5, 6], [ 8, 10, 12], [12, 15, 18]]) * * Pytorch torch Reference Manual](#)
← Pytorch Torch PermutePytorch Torch Orgqr β†’