PyTorch torch.ger Function
Pytorch torch Reference Manual
torch.gerIt is a function in PyTorch used to compute the outer product (Gram matrix) of two vectors.
Function Definition
torch.ger(input, vec2, out=None)
Usage Example
Example
import torch
# Create two vectors
vec1 = torch.tensor([1, 2, 3])
vec2 = torch.tensor([4, 5, 6])
# Compute the outer product
result = torch.ger(vec1, vec2)
print("Outer product result:")
print(result)
# Create two vectors
vec1 = torch.tensor([1, 2, 3])
vec2 = torch.tensor([4, 5, 6])
# Compute the outer product
result = torch.ger(vec1, vec2)
print("Outer product result:")
print(result)
The output result is:
tensor([[ 4, 5, 6],
[ 8, 10, 12],
[12, 15, 18]])
Other Extensions