Rate this Page

torch.outer#

torch.outer(input,vec2,*,out=None)Tensor#

Outer product ofinput andvec2.Ifinput is a vector of sizenn andvec2 is a vector ofsizemm, thenout must be a matrix of size(n×m)(n \times m).

Note

This function does notbroadcast.

Parameters:
  • input (Tensor) – 1-D input vector

  • vec2 (Tensor) – 1-D input vector

Keyword Arguments:

out (Tensor,optional) – optional output matrix

Example:

>>>v1=torch.arange(1.,5.)>>>v2=torch.arange(1.,4.)>>>torch.outer(v1,v2)tensor([[  1.,   2.,   3.],        [  2.,   4.,   6.],        [  3.,   6.,   9.],        [  4.,   8.,  12.]])