Search code examples
pytorchmultiplicationtensor

Multidimensional tensor product in PyTorch


In pytorch I have to tensors of dimensions [K,L,M] and [M,L,N]. I want to perform a standard tensor convolution product of those tensors along the middle two dimensions to obtain a [K,N] tensor. I couldn't find official documentation on how to perform those operations, perhaps it should be better done in some other library and then reconverted to pytorch tensor?


Solution

  • If by convolution you actually mean something like contraction, you're probably looking for torch.tensordot. You can specify the indices that should be contracted.