PyTorch torch.ger function
PyTorch torch reference manual
torch.ger A function in PyTorch for computing the outer product (Gram matrix) of two vectors.
Function definition
torch.ger(input, vec2, out=None)
Usage examples
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
)
(
"Outer product result:"
)
(
result
)
The output is:
tensor([[ 4, 5, 6],
[ 8, 10, 12],
[12, 15, 18]])